5.1 Backtesting in the strategy tester
A backtest runs the robot on historical data, as if it had traded in the past. It is the fastest way to find out whether an idea is worth working on.
How to start a test
MetaTrader 5: Open the Strategy Tester (Ctrl+R). Choose the robot, market, time frame and period. Choose the model Every tick based on real ticks if the broker has such data. Press Start.
MetaTrader 4: Ctrl+R, choose the robot and market, model Every tick, and press Start.
cTrader: Choose the robot in the Algo app, open the Backtesting tab, choose a period and Tick data, and press play.
Important settings
- Period: At least one to two years, preferably more. Include both quiet and volatile periods.
- Spread and commission: Use realistic values. Many strategies that look profitable with zero spread lose money with a real spread.
- Starting capital: The same amount you actually intend to use.
The figures to look at
| Figure | What it tells you |
|---|---|
| Net result | Did the robot make money – after costs? |
| Number of trades | Fewer than 100 trades gives an uncertain picture |
| Win rate and average win/loss | The profile of the strategy |
| Profit factor | Gross profit ÷ gross loss. Above 1.3–1.5 is good after costs |
| Maximum drawdown | The largest fall from peak to trough. Could you live with it? |
| The equity curve | Smooth and rising, or a few big wins? |
The pitfalls
Ernest Chan describes several classic mistakes in Quantitative Trading:
- Look-ahead bias: The robot uses information it could not have had – for example the close of the candle that is still open. That is why we use candle 1.
- Bad data: Gaps and errors in the history give wrong results.
- Too few trades: A few lucky trades can create a good result.
The backtest is the best case
A backtest has no slippage you have not added, no technical faults and no emotions. Live results are almost always worse than in the test. Count on it.
Try it yourself
Run the robot on two periods separately. Are the results similar? Note the number of trades, the win rate and the maximum drawdown.
Key takeaways
- Test on at least one to two years with realistic spread and commission.
- Look at the number of trades, profit factor, drawdown and the equity curve.
- Live results are almost always worse than the backtest.
65% of retail investor accounts lose money when trading CFDs with this provider.