Look-ahead bias

Look-ahead bias: how backtests cheat without telling you

If a test uses anything you could not have known at that moment, its results are inflated. These are the leaks that matter, and how to close them.

Three common leaks

Higher-timeframe closes

A 1-hour candle is unknown until the hour ends. A replay that shows it early hands you the future. Ours builds it bar by bar.

Repainting indicators

Swings and order blocks are only confirmed later. A tool that draws them back at the origin looks perfect in hindsight. Our detectors act on closed bars, and tests check they never repaint.

You

Once you've seen the chart, you can't unsee it. Writing rules down first, and grading each order at placement, is the practical defence.

Stop and target in the same candle

A candle shows the high and low, not which came first. Assuming the target hit first flatters every test. FX Battlefield counts the stop and flags the trade, so uncertain trades lean against you.

A quick check of any backtest

  1. Could each input be known when the order was placed?
  2. What happens when stop and target share a candle?
  3. Are spread, commission and slippage included?
  4. Were the rules fixed before the test began?

Costs deserve their own look: see spread, commission and swap in backtesting.

Read next

Questions

What is look-ahead bias?

Using information in a test that was not available when the trade would have been placed.

What is repainting?

When an indicator changes its past values after new bars arrive, so its history looks better than it did live.

Test it on your own rules.

Open the replay, free