Request for AFL - Backtesting of a System.

veluri1967

Well-Known Member
#1
Hi,

Any trend following system ie., KPL Swing or Kama System or Asnavale's 20 Wilders.

I would like to backtest these systems with the following criteria on Amibroker both on intraday data and EOD data.

When a buy signal is generated.

1. Buy Initial lot = 400 (or 4 lots for futures)
2. When the price moves upward by 1.5 ATR of MA 60 add another 200 (or 2 lots for futures).
3. When the price moves upward by another 1.5 ATR of MA 60 add another 100 (or 1 lot for futures).
4. And other adds for each upward move is 100 each (or 1 lot for futures).
5. And there is no limit for adds.

When price retraces by 1.5 ATR of MA 60 book 50% of the holdings until then.


Many scenerious likely to be encountered.

1. After buying initial lot, price never touches ADD and a sell signal is generated. Exit all.
2. After buying initial lot, 1st ADD is taken and then price retraces by 1.5 ATR from peak of high and we book 50% of holdings ie 300. And keep remaining to sell on sell signal if price stops moving up.
3. After buying initial lot, 1st ADD is taken and then price retraces by 1.5 ATR and we book 50% of holdings. And then price resumes its upward movement. We donot add at profit booked price + 1.5 ATR. But we wait to add until the price touches 2nd ADD point. But here we add only 50% of present holdings or 100 whichever is less.

Likewise it goes on until a final sell signal is given. When a final sell signal is given we exit all the positions.

And we take short positions.
and the position sizing goes on for shorts as well.

If somebody can write AFL for this backtesting i would be grateful.:)
 

Similar threads