A backtest runs a trading strategy over historical prices to see how it would have behaved. It is the cheapest way to reject a bad idea — and the easiest way to fool yourself about a mediocre one.

Backtesting in MetaTrader

The MetaTrader Strategy Tester replays history bar by bar or tick by tick. Key settings that change results dramatically:

  • Modelling quality — “every tick based on real ticks” is far more realistic than “open prices only”, especially for scalpers and EAs with tight stops.
  • Spread — a fixed low spread flatters results. Use a realistic or variable spread.
  • Commission and swap — must be included; holding positions overnight has a cost or credit.
  • Date range — short ranges hide bad regimes. Include calm and volatile years.

In-sample, out-of-sample, walk-forward

  1. In-sample: the period used to design and tune the strategy.
  2. Out-of-sample: a later period kept untouched until the design is frozen. One look only — reusing it turns it into in-sample data.
  3. Walk-forward: repeatedly optimise on one window and test on the next, rolling forward through history. It better imitates how a strategy is actually maintained.

Forward testing

After a backtest, a strategy is usually run on a demo account or a very small live account for months. Forward testing reveals things history cannot: real execution, requotes, slippage, server outages and broker-specific conditions. Demo fills are often better than live fills, so even a good demo record is not the end of the story.

Classic backtesting mistakes

  • Look-ahead bias — using information that would not have been available at the time (for example the close of the current bar).
  • Survivorship and selection — showing the one configuration that worked out of hundreds tested.
  • Curve fitting — too many parameters tuned to one period.
  • Ignoring costs — the most common reason a backtest edge disappears live.
  • Too few trades — 40 trades cannot tell skill from luck.
A useful habit: before looking at the equity curve, write down what result would make you abandon the strategy. Then honour it.
Risk reminder. Trading foreign exchange and CFDs on margin carries a high level of risk and may not be suitable for every investor. You can lose more than your initial deposit. Past or simulated performance of any trading system, including automated Expert Advisors, does not guarantee future results.