[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Changing the stop loss depending on the stock price?



PureBytes Links

Trading Reference Links

Hi Thomas,

Those links helped me a lot.  Thanks!

I still have some questions however.  I now better understand the "for" statement, but could you please give me some precision on this?

priceatbuy=0;
highsincebuy = 0;
exit = 0;
for( i = 0; i < BarCount; i++ )
    {
        if( priceatbuy == 0 AND Buy[ i ] )
            {
                priceatbuy = BuyPrice[ i ];
            }
        if( priceatbuy > 0 )
            {
                highsincebuy = Max( High[ i ], highsincebuy );
                if( exit == 0 AND
                    High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) * priceatbuy)

                       

I now understand that for each bar "i", the program now looks if the bar value is less than the barcount and then apply the formula below.  But what I don't understand there is how can "priceatbuy" differ from 0 since it was defined as 0 just over (first line of the code).  How could "priceatbuy", which was given a value of 0 could have a value over 0 then?

I understand that the bar in which a buy was issued is represented as Buy [i], but why the "priceatbuy ==0" before? 

Thank you!

Louis





2008/2/23, Thomas Ludwig <Thomas.Ludwig@xxxxxx>:

> I don't understand what's the "i" for and why i++ (I know ++ is
> suppose to mean that each number is added to the one before, but I am
> not sure of how this code actually helps me).  If someone could just
> tell me what this thing is actually doing, it would really help me to
> understand that code.


This is described in the manual or on
http://www.amibroker.com/guide/a_language.html and
http://www.amibroker.com/guide/keyword/for.html

Regards,


Thomas




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html


Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/


__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___