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

[amibroker] Top Stop Exit programming question



PureBytes Links

Trading Reference Links

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);


------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL 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/