This article is specific to Amibroker backtest, but can be applied to other backtest methods/engines as well.
Amibroker backtest engine is one of the best available out there. It will do the days of task in couple of minutes. You can exactly simulate your equity portfolio like real (- slippages). It has many options that will allow you to backtest your equity in number of ways. Mastering Amibroker backtest requires lots of time
You might have seen backtest reports with huge returns, ever tried to decode the report?, wondered about huge returns? , have asked yourself whether such huge return possible?
Let’s check it out
Most of the backtest results posted in the public domain are not real, but manipulated. Some are manipulated intentionally, some due to negligence and coding mistake.
A slight modification in the AFL code may change the backtest results drastically. Below are the most common things which affects backtest result.
Ways to manipulate backtest results
- Assigning wrong trade prices
- Using Future bars
- Over Optimization
- Compound Backtesting
- Backtesting with Penny Stocks
- Not including Commissions
1. Assigning wrong trade prices
This is the most common reason for misleading or wrong backtest results. Check the below image
Let’s check this with sample trading system (ORB). On the left, we have correct trade price assigned and on the right, we used open price as trade price. We risked 2% of our capital on each trade.
BuyPrice = ValueWhen(Buy, IIf(O>BuyLevel,O,BuyLevel));
ShortPrice = ValueWhen(Short, IIf(O<ShortLevel,O,ShortLevel));
BuyPrice = ValueWhen(Buy, O);
ShortPrice = ValueWhen(Short, O);
2. Using Future Bars
Want to be a millionaire in couple of months? Just include functions which uses future bars in your Signal code. Example: Peak, Trough, ZigZag
You will see Buy/Sell/Short/Cover signal arrows in static chart, but those signals will never come at the Last Bar in live trading.
Using future bars means, after the stock moved a lot, you are going back to the past and buying that stock at low prices, so you are basically a time traveler.
You can download the Make-Me-Millionaire AFl from the below link
3. Over Optimization
Any trading logic when optimize, will give profit at certain points. For example you can optimize the target and stoploss percentage with Amibroker. In the below example, we optimized AXISBANK stock with 2% risk on capital.
Target%: Min-0.1 Max-3.0 Step-0.1
Stoploss%: Min-0.1 Max-3.0 Step-0.1
and we found that the sample system gave max profits at Target-2.9 and Stoploss-0.2
But, the problem with over optimize is, very less chance to replicate.
4. Compound Backtesting
It is also possible to manipulate the backtest results by doing compound backtest i.e. reinvesting profit OR by utilizing 100% of our capital
Take our ORB example at point 1, we risked 2% of capital per trade and the quantity calculation is based on our Initial capital only. Let see what if reinvested the profit and keeping same 2% risk on outstanding capital
Our return is doubled
5. Backtesting with Penny Stocks
A few ticks movement will show high return in backtest result, but in reality you may have to face issues like liquidity, slippages etc
6. Not including Commissions
Take our ORB example at Point 1, if we not include commissions, then the returns will be ~10%