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

Trailing Stops



PureBytes Links

Trading Reference Links

I’m just getting started with AmiBroker, and have spent a lot of time trying to deduce 
the rules it uses for implementing trailing stops in backtesting.

After awhile I tried using disabling the Trailing Stop settings in the System Test 
Settings window and replacing them with a formula that I thought would do the same 
thing: 

Sell = Low < (1-TrailingStop)* Ref(High,-1)

However, it appears to me that this results in the Exit price = the Open price rather 
than = the Stop price. How can I modify the formula to get the Exit price= the Stop 
price (= the results of using the default Trailing Stop settings with “Exit at stop” 
checked)?

Also, is there any way I can get AmiBroker to ignore the Trailing Stop on the day of 
the Buy? I’m aware of the IFF and DAY functions, but I don’t see any way to get the 
BuyDay. I tried

StopLoss = (1-0.01) * BuyPrice;
TrailingStop = (1-0.016)* Ref(High,-1);
Sell = Low < Max(IIf(BarsSince(Buy)=0,StopLoss,TrailingStop),StopLoss);

but it apparently didn’t like the BarsSince(Buy).

Thanks,

Damien