Amibroker Forum (Unofficial)

Trading Related => Trading System Discussion => Topic started by: morgen on May 18, 2010, 08:54:44 am

Title: Trailing Stop ATR
Post by: morgen on May 18, 2010, 08:54:44 am
Is there somebody who can put on Wisestocktrader "Trailing Stop ATR" formula, BASED ON " k* ATR" AND " HH AND LL"  FROM 3 DAYS AGO, for AmiBroker?
Thank You!
Title: Re: Trailing Stop ATR
Post by: administrator on May 18, 2010, 08:14:11 pm
I don't have the other trailing stops you asked for but here is the ATR trailing stop loss
Code: [Select]
// ATR Trailing stop - stevo 2006
// When stop line drops exit is triggered.
multiplier = Param( "ATR Multiplier", 2, 0, 10, 0.1 );
myATR = multiplier * ATR( 15 ); // calculate ATR
initial = C - myATR; // raw stop - not racheted

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 ];
}

Plot( stop, "ATR Stop", colorRed, styleLine );

Sell = C < Ref( stop, -1 );

PlotShapes( IIf( stop < Ref( stop, -1 ), shapeDownArrow, Null ), colorOrange, 0, H );