Backtesting
By Chad Smith, Director of Research & Analysis · Updated
Backtesting is the process of applying a trading strategy's rules to historical price data to see how it would have performed in the past.
Worked example
Example: a trader has a simple rule set for EUR/USD on the four-hour chart:
- Buy when price closes above the 50-period moving average after being below it.
- Stop-loss 40 pips below entry.
- Take-profit 80 pips above entry.
They run the rules on several years of data and record every trade. Suppose the results show 200 trades, a win rate of 38%, and a max drawdown of 18%. With a 1-to-2 risk-reward ratio, a 38% win rate gives a small positive expectancy before costs. After adding spreads and commission, the edge almost disappears. These results are invented for the example.
Why it matters to a trader
Backtesting lets you check an idea before risking money. It shows:
- Whether the rules have any edge at all.
- How large the drawdowns and losing streaks could be.
- How sensitive the results are to costs and settings.
It also builds confidence to follow the rules during bad stretches, because you have seen them before in the data.
Common confusions
- Overfitting. Tuning settings until past results look perfect usually produces a strategy that fails on new data. See overfitting.
- Costs and slippage. Leaving out the spread, commission and slippage makes results look better than they would be.
- Look-ahead bias. Using information that would not have been known at the time, such as a candle's close before it closed, inflates results.
- Backtest versus forward test. A forward test runs the strategy on new data in real time, which is a stronger check.
Related terms
Where to practice this
Put this into practice on a demo account first, with no money at risk.
- Featured broker
Pepperstone4.7 / 5Visit
IC Markets4.9 / 5Visit
GO Markets4.8 / 5Visit
Frequently asked questions
Can I backtest without coding?
Yes. Manual backtesting means scrolling through past charts and recording each trade your rules would have taken. Some platforms also offer replay tools.
Does a good backtest mean the strategy will work?
No. Past results do not guarantee future results, and backtests can be distorted by overfitting, missing costs and unrealistic fills.
How much data should I use?
Enough to include different market conditions, such as trends, ranges and volatile periods, so results are not tied to one type of market.
Which platforms support backtesting?
MetaTrader has a built-in strategy tester, cTrader has cBot backtesting, and TradingView supports strategy scripts.