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

[amibroker] Coding Problem



PureBytes Links

Trading Reference Links

Hello All,

I'm tryin to code a trailing stop loss but am having a number of 
problems with writing the code.

What I'm trying to achieve is:

1. Once a Buy signal appears from my system, the value of the current 
AccDist() Line should be recorded.

2. As long as the AccDist() moves upwards the trade should remain 
open.

3. However, once the AccDist() line falls by a certain percentage 
(say 10% for this example) from its Highest value since the trade was 
opened, the trade should be stopped out.

I have some code for a simple trailing stop based on the Low of the 
price (see below) but I'm not sure how to modify it to accomplish the 
above.

Any ideas would be most welcome...


Initial = LLV(Low,5);

stop[0] = Close[0];
for( i = 1 ; i < BarCount; i++)
{ 
 if( Close[i] > stop[i-1]) 
 { 
  stop[i] = Max( initial[i], stop[i-1] ); 
 }
 else { stop[i] = initial[i]; }
}

Plot( stop, " Stop Loss", ParamColor("Color", colorCycle ), ParamStyle
("Style", styleDots | styleNoLine, maskDefault | styleDots | 
styleNoLine ) );


Many Thanks in advance,

Chorlton



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/