Look-ahead bias and other traps

Using information you would not have had at the time, ignoring costs and other common backtest errors.

All courses · Lesson 5 of 6 · Advanced · 4 min

Some backtest errors make results look better by using information the strategy could not have had, or by leaving out costs that real trading charges. This lesson lists the common traps so you can look for them in your own tests.

Using information from the future

Look-ahead bias means a rule uses data that was not yet known when the decision would have been made. Because a backtest has the whole history on hand, it is easy to do this by accident.

  • Entering at a candle's open using that same candle's close to decide. The close is unknown until the candle ends, so the earliest realistic entry is the next candle's open.
  • Using the day's high or low before the day has finished, for example buying "at the low of the day".
  • Indicators that repaint, meaning their past values change when new candles arrive, so the chart looks perfect in hindsight but gave different signals live.
  • Survivorship bias: testing only on instruments that still exist today, which leaves out the ones that failed or were delisted.

In a node graph, a good habit is to ask for every input: was this value final at the time the entry is evaluated? The PreviousValue node, which gives the value one candle earlier, is a common way to make sure a signal uses only completed information.

Ignoring the cost of trading

A backtest that ignores spread, commission and slippage overstates results, and the damage is largest for strategies with tight stops or many trades. Costs are best expressed in R, so they can be subtracted from the expectancy directly.

Worked example

A cost that erases most of an edge

  1. The rules show a gross expectancy of +0.10R per trade over 200 trades, which is 200 × 0.10 = +20R in total.
  2. The stop is 10 pips and the typical spread is 0.8 pips, so each trade costs about 0.8 / 10 = 0.08R.
  3. The net expectancy is 0.10 − 0.08 = +0.02R per trade.
  4. Over 200 trades the net total is 200 × 0.02 = +4R instead of +20R.

Ignoring a spread of 0.8 pips made the strategy look five times better than it is (20R against 4R).

Other common traps

Assuming perfect fills at exactly the quoted price, testing on data with gaps or errors, and choosing the instrument or period after seeing which one worked are all variants of the same mistake: letting the answer shape the test. Each makes the backtest more favourable than reality.

A checklist for your own tests

Because these errors are easy to make and hard to see in a summary, it helps to run through the same questions every time you finish a backtest. None of them needs special tools, only the habit of asking.

  1. At what moment is each entry decided, and was every input already final at that moment?
  2. Does any indicator change its past values when new candles arrive?
  3. Are spread, commission and slippage included, and are they realistic for the instrument and time of day?
  4. Was the instrument and the period chosen before seeing the results?
  5. Does the data include instruments or periods that ended badly, not just the ones that survived?
  6. Do the replayed trades sit where the rules say they should?

Key takeaways

  • Look-ahead bias is using data that was not known at decision time, such as a candle's close to enter at its open.
  • Repainting indicators and survivorship bias make past results look cleaner than anything achievable live.
  • Costs matter most for tight stops: a 0.8 pip spread on a 10 pip stop is 0.08R per trade.
  • Replay individual trades to confirm that every input was known when the entry was evaluated.

Sign in to save your progress and quiz results.