Australian (ASX) Stock Market Forum

Amibroker - trailing stop with tightening ATR

Joined
29 January 2010
Posts
83
Reactions
0
Hi all,

Trying to test out a tightening trailing stop e.g. when the profit > 50% use an ATR of 1.5 vs 3. I have added the trailing stop code below. I am struggling to modify it to work with my requirement.

Any suggestions? :eek:

// Assign conditions ------------------------------------------------------
// Set the trailing stop (also used to set the position size)
Trail = ATR(Period_ATR) * TrailATR;

myATR= Trail ; // calculate ATR
initial=C-myATR;

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