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

Re: [amibroker] Trailing sttops



PureBytes Links

Trading Reference Links

Hi Nikku,

Thanks for the great explanation...makes it easy to follow and 
understand..now, i have a further question.

How do I get the trailing stop to move up further as the price moves up? 
That it, not just move up once and place a new stop and wait for a 
retracement, but move the stop up again after a further x% rise in the 
price? Basically, if the price keeps rising, the stop keeps moving up.

Thanks,

Andrew.

> The answer involves an analysis of this part of the code - keep it in
> mind for what follows
>
> *pct=IIf((MA(C,2)-buyat)/buyat > MinGainPct,trailPct,9999);*
>
> MinGainPct is expressed as .04 because of the* (MA(C,2)-buyat)/buyat*
> element of this line of code. Let's say that the close for the past two
> days has been $10.00. We have bought at $10.50. The calculation for
> 'pct' would then be
>
> MA(C,2)-buyat/buyat
>
> ($10-$10.5)/$10.5 =  app.-0.0476
>
> At this moment,
>
> *(MA(C,2)-buyat)/buyat IS NOT GREATER THAN MinGainPct
>
> *(Remember, MinGainPct has been set at 0.04; -0.476 is clearly not
> greater than 0.04)
> *
> *so the 'pct' variable will feed the trailing stop with 9999; in other
> words, the trailing stop will kick in when 9999% of the profit has been
> given back - this is just a way to say 'The trailing stop is NOT 
> activated'.
>
> Now let's say the closing price goes up and one day  we close at $12.20;
> the day before this, the close was $11.80. The MA(C,2) in this case will
> be $12.00. If we insert this new number into the formula, we get
>
> MA(C,2)-buyat/buyat
>
> ($12-$10.5)/$10.5 =  app.0.143
>
> At this moment,
>
> *(MA(C,2)-buyat)/buyat IS GREATER THAN MinGainPct (which is 0.04)
>
> *Now the 'pct' variable will feed the trailing stop with the 'trailpct'
> value because the conditions for activation of the trailing stop have
> been met  - that is,
> (MA(C,2)-buyat)/buyat [which now equals 0.143] has been calculated to be
> greater than the MinGainPct (0.04).
>
> Of course you can change the value of MinGainPct to suit your needs.
>
> Trailstop does signify the amount you allow the trade to retrace (once
> it gets past the MinGainPct threshold) before exiting.
>
> Hope this helps




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

<*> 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/