Backtesting and forward testing: validate a strategy before you trade it
- A backtest measures what a rule would have done in the past; a forward test checks that it holds up in the present.
- The larger and more varied the sample of trades, the more the result is worth.
- A strategy fitted too tightly to the past wins on historical data and loses in the live market.
Trading a strategy you haven't tested means paying the market to find out whether it works. Backtesting and forward testing let you do that work before risking real money, or at least with far less money on the line.
The principle is simple: apply precise rules to price data, log each trade as if you'd taken it, then work out the stats. The hard part is staying honest, because you already know what the chart did next.
Manual backtesting
You open a chart, scroll back several months or years, then move the candles forward one at a time. Every time your setup appears, you note the entry, stop, target and result. Most platforms have a replay feature that hides future candles.
For each simulated trade, record the same details as in your real journal: date, instrument, direction, entry, stop, target, result in R, and the market context (trend, range, upcoming release). A spreadsheet is enough. What matters is being able to recalculate your stats at the end, and to find each trade again to review it.
The upside: you learn a huge amount. You see your setup hundreds of times, in all kinds of conditions, and your eye gets trained. The downside: it's slow, and it's tempting to "see" setups that weren't really there, because you already know where price went.
Replay · what do you do?
InteractivePrice is testing resistance for the third time. Make your call, then watch what happens candle by candle.
Automated backtesting
Here you turn your rules into code (in a platform language such as MQL for MetaTrader or Pine Script for TradingView), and a program tests years of data in seconds. That requires every rule to be fully mechanical: no room for "looks good to me".
Automated backtesting is fast and free of reading bias, but it has its own traps. Historical data can be poor quality. Real spreads, slippage and commissions are often badly modelled. And a small coding bug can produce stunning results that are completely wrong.
| Manual backtest | Automated backtest | |
|---|---|---|
| Speed | Slow | Very fast |
| Discretionary rules | Possible | Impossible |
| Reading bias | High | None |
| Visual learning | Strong | Weak |
| Main risk | Cheating without meaning to | Bugs or badly modelled costs |
How many trades should you test?
Twenty trades tell you almost nothing. With a sample that small, luck can produce a very good or very bad run. The more trades you collect, the more likely the gap between your test result and the strategy's true behaviour is to shrink. Many traders set themselves a minimum of around a hundred trades per setup before drawing any conclusion.
Numbers alone aren't enough: you also need variety. Test your strategy in trends, in ranges, in quiet periods and in volatile ones. A method tested only during a strong rally in gold tells you nothing about how it behaves when the market goes sideways.
- Strategy win rate
- 50%
- Probability of losing one trade
- 0.5
- Probability of losing 5 given trades in a row
- 0.5 × 0.5 × 0.5 × 0.5 × 0.5
- Result
- 0.03125, or about 3.1%
Over a single sequence of 5 trades, that's rare. But across hundreds of trades there are many sequences of 5, so a run of 5 losses becomes perfectly normal.
Forward testing on a demo account
A backtest is still a simulation on known data. Forward testing means applying the strategy in real time, on a demo account, without knowing what comes next. You take trades as they appear, with real spreads and real execution conditions, and you log them in your journal.
A forward test exposes what a backtest hides: the setups you miss because you weren't at the screen, the hesitation, the late entries, the economic releases that distort a trade. If your demo results differ sharply from your backtest, find out why before going any further.
The overfitting trap
Overfitting means tweaking parameters until the backtest looks perfect: a 47-period moving average instead of 50, RSI at 31 instead of 30, a time filter set to the minute. The result fits the past perfectly, but it has learned the noise in the data, not genuine market behaviour.
- Keep parameters few: the more settings a strategy has, the more likely it's been fitted to randomness.
- Split your data: optimise on one period, then check on another period you've never used.
- Check robustness: if moving from 50 to 45 or 55 periods wrecks the result, the edge isn't solid.
- Be wary of perfection: a backtest equity curve with no drawdown at all is almost always a red flag.
From historical data to a live account: the order of steps
Each step filters out strategies that don't hold up. Skipping one means discovering your method's flaws with your own money, at the moment they cost the most.
- Write the rules precisely enough that someone else could apply them without you.
- Backtest on a large sample, with real costs (spread, commission, swap) included in the calculation.
- Check on a period you've never used to make sure the result doesn't come from fitting the past.
- Forward test on demo for several weeks, logging every trade in your journal.
- Go live with very small risk, then compare your real stats with your test stats.
Check your understanding
0 / 3Educational content, not investment advice. Leveraged trading carries a high risk of losing money rapidly: most retail investor accounts lose money on these products.