Look-ahead bias
Find the information a backtest used before it existed. · 7 min
ProOpen to everyone while Pro is in preview.
Look-ahead bias is a backtest using data that was not available when the decision was made. It rarely looks like cheating. It looks like an off-by-one error.
Predict first
The “up close” rule loses a little on the no-edge market. Now the same rule buys at the open of the up day itself instead of the next open. What happens?
Spot the look-ahead
One rule, “buy after an up close”, backtested three ways on a market with no edge. Two of them use information that did not exist at the moment of the trade.
Running the numbers…
Where look-ahead hides
- Entering at a price from the same candle that produced the signal.
- Indicators computed over the whole history: normalising by the full-sample average, fitting a trend line through all the data, or a “centred” moving average.
- Using the day’s high or low to place an order that would have been filled earlier.
- Fundamental data stamped with its period, not with the day it was published.
- Index membership or a stock list taken from today (also survivorship, next lesson).
A useful test: cut the history at day i and ask the signal again. An honest signal gives the same answer with or without the future attached. Our simulator is built this way: the next candle does not exist until it is revealed.
Worked example
Rule: “buy at the open when the day closes above its open”. On the open, the close is hours away. If the day did close above its open, buying at the open made money by definition: a perfect win rate for the first day of every trade. In our ten years, that bug turns 41.5% winners into 50.7%, and a signal that reads tomorrow’s close does almost the same (52.4% winners, +0.186R per trade).
Common mistake
Trusting a result because it is good. A backtest that is too smooth or too profitable is more likely a bug than a discovery. Find the leak before you celebrate.
Closing round
Find the flawed backtest
Three reports on the same ten years. One of them could never be traded as written.
Building a fresh case…
Further reading: Aronson, Evidence-Based Technical Analysis, chapter 1 (look-ahead and other biases).