A backtest is only as honest as the information it was allowed to use. Look-ahead bias is what happens when a test quietly uses data that a trade could not possibly have known at decision time. It is the silent killer of good-looking strategies precisely because it never shows up as an error — it just inflates results until reality corrects them with real money.
What look-ahead bias actually is
At every point in a backtest, the strategy is making a decision "as of" a moment in time. Look-ahead bias is feeding that decision something from the future: a close price before the bar has closed, a high or low that was not yet known, an indicator computed over data that had not arrived. Each leak lets the test cheat, and a cheating test always looks brilliant.
How it sneaks in
- Using the close too early. Acting on a candle's close at any time before that candle has actually closed.
- Whole-series calculations. Computing an average, a high, or a normalisation across the entire dataset, then applying it to points that came before the data existed.
- Survivorship and revisions. Testing only on pairs or data that survived to today, or on values that were later revised, neither of which a trader had at the time.
- Peeking labels. Tuning on the same data you then report as the result, so the strategy has effectively seen the answer key.
A worked example: one bar of leakage
Look-ahead bias rarely announces itself; it hides in the timing of a single value. Picture a strategy that buys when price closes above its 20-period average. The table contrasts the honest version, which can only act on a candle once it has closed, with a leaked version that acts on the close while the candle is still forming.
| Step | Honest test | Leaked test |
|---|---|---|
| Decision uses | Last closed bar | Current forming bar's close |
| Earliest possible entry | Next bar's open | This bar's close — impossible live |
| 100-trade win rate | 54% | 71% |
| Modelled net per trade | +8 bps | +39 bps |
| Holds out-of-sample? | Yes, gently degraded | Collapses — the future is gone |
The leaked column looks vastly better — a 71% win rate and nearly five times the per-trade edge. That gap is not skill; it is the test buying at a price no live order could have reached, because the bar had not closed when the decision was made. Walk-forward validation exposes it instantly: the moment the strategy meets data it was not tuned on and cannot peek at, the inflated edge evaporates.
Why excluding it is non-negotiable
A strategy that beats the market with a leak has proven nothing except that it can read the future — which it cannot do live. The realistic cost model and the strict separation of tuning data from validation data both exist to slam this door shut. The discipline is simple to state and hard to keep: at every decision, the test may only use what was knowable then.
Common questions
Is look-ahead bias the same as overfitting?
No, though they often travel together. Overfitting is memorising noise in data you were allowed to see; look-ahead bias is using data you were never entitled to see at decision time. Both inflate in-sample results — the distinction matters when you fix them, as how to spot overfitting in a strategy sets out.
How do I know my own backtest doesn't leak?
The structural test is the gap. If results that look stellar in-sample fall apart on unseen data, suspect a leak. In-sample vs out-of-sample, explained shows why that gap is the whole game, and survivorship bias in crypto backtests covers a sibling leak that hides in your choice of pairs.
Doesn't a realistic cost model fix this?
It helps, but cost modelling and leak prevention solve different problems — one charges for friction, the other forbids future knowledge. A leaked test with perfect costs is still fiction. See the backtesting myths that cost traders money for how a clean-looking curve fools people.
The cleanest defence is structural. Read walk-forward testing explained to see how rolling, unseen validation windows make look-ahead leaks obvious, then learn how to spot overfitting in a strategy for its close cousin. A test that survives both still earns only a trip to paper trading, never a straight path to live.