Backtesting

Backtesting is the process of applying a trading rule to historical price data to see how it would have behaved. It tests the rule's internal logic and the quality of the data, not the future. Any figure it produces is a hypothetical result, because no order was ever sent to a market.

What has to be true before a result means anything

Most backtests fail on their inputs rather than on their logic.

  • Costs inside the test. Spread, commission and overnight financing are charged on every position in the market, so they belong in the test arithmetic. A rule tested on mid prices is a rule tested on prices nobody trades at.
  • Data granularity. Bar data records four prices per bar and says nothing about the path between them. If a rule can hit both its protective level and its target inside one bar, bar data cannot tell you which came first; tick data can, and only for the period the tick history covers.
  • Period length and coverage. A window must contain more than one market condition — trending and ranging, calm and volatile, at least one policy cycle. A rule tested on a single condition has been tested once, not many times.
  • Held-out data. Parameters chosen on one period should be examined on a period that was not used to choose them. Without that separation there is no way to tell fitting from finding.

Four standard errors

Curve fitting. Parameters are adjusted until the historical output looks its best. Each extra parameter adds ways to describe the past exactly; the description then belongs to that sample and to nothing else. Fewer parameters and stable behaviour across neighbouring values are worth more than a single flattering setting.

Look-ahead bias. The test uses information not available at the decision moment: a close price used inside the bar it closes, a revised economic figure rather than the first release, an index constituent list as it stands today. The rule appears to know things it could not have known.

Survivorship bias. The instrument list contains only what still exists. Delisted shares, discontinued contracts and currencies that were re-pegged or abandoned drop out of the sample, so the sample describes the survivors.

Ignored execution. Fills are assumed at the requested price. Real market and stop orders fill at the next available price, gaps jump past levels entirely, and requotes leave intended trades unfilled.

Why a historical result does not carry forward

Under Article 44(5) of Delegated Regulation (EU) 2017/565 a backtest is simulated past performance, and Article 44(6)(a) bars information on future performance from being based on or referring to simulated past performance. No performance figures are quoted here for that reason.

The substantive point is not regulatory. A backtest measures one rule against one recorded sequence of prices that has already happened, under one set of costs and one execution assumption. Volatility regimes change, spreads and swap rates change, liquidity conditions at a given hour change, and the relationships a rule keys on are not stable properties of a market. A clean test tells you the rule was implemented correctly and survived a wide sample; it does not transfer that sample's outcome to a period the market has not produced yet. Treat the output as a filter that removes broken rules, not as a forecast.

Related terms

Make Your First Move in the Market

Open your trading account in minutes and start building your strategy with powerful trading tools.

66.7% of retail investor accounts lose money when trading CFDs with this provider. Assess if you're comfortable with this level of risk. Read more