Hi,

I am trying to program the Top Stop Exit as described by Volker Knapp in 
the September 08 edition of Active Trader Magazine.

The entry rule is a basic moving average cross (for the trend strategy) 
over but the exit is giving me trouble.

The exit uses a limit order which adjusts up or down depending on the 
volatility.

The rules are:

Limit exit: 4.5 times the ATR(14) plus the absolute value of todays 
closing price minus yesterdays closing price.
If the closing price is highest of the past 20 days, raise the exit by 
the absolute value of todays closing price minus yesterdays closing price.
If the price fails to make a new 20 day high, lower the exit price by 
the same amount.

Any help would be appreciated.

Thank you.




/* from active trader mag. sep 08, p.54  */



SetTradeDelays(1,0,1,0);

BuyPrice = C;

Buy = Cross(C,MA(C, 100));


Entryprice = 0;

Limitexitprice = 0;


for (i=0; i < BarCount; i++)
{

    if (Entryprice == 0 AND Buy[i] == 1)
    {
        Entryprice = BuyPrice[i];
        Limitexitprice = Entryprice + ATR(14)*4.5 + abs(C-Ref(C,-1));
    }
    else
        
        if (Entryprice > 0 AND H[i] > Limitexitprice[i])
            {
                Sell[i] =1;
                SellPrice[i] = Limitexitprice;
              Entryprice = 0;
           }
        else

        if (Entryprice > 0)
            {
                Limitexitprice = IIf(C > HHV(C,20),
                         Limitexitprice + ATR(14)*4.5 + abs(C-Ref(C,-1)),
                         Limitexitprice + ATR(14)*4.5 - abs(C-Ref(C,-1)));
            }



}

Sell = Cross(C, Limitexitprice);



Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Reply via email to