Look-ahead bias
Look-ahead bias is when a backtest lets your strategy peek at something it couldn’t possibly have known at the time.
It’s rarely deliberate and it’s often invisible. Here’s the classic version:
Buy any stock that finishes the day up more than 3%.
Run that over history and it looks wonderful. But you can only know that a stock finished the day up 3% after the close — and the backtest, if you’re not careful, buys it at that day’s opening price. You’ve bought at 9:30 using information from 16:00. In reality you’d have bought the next morning, after everyone else already knew.
Why it’s so easy to do by accident
Daily price data arrives as one tidy row per day: open, high, low, close, volume. The whole row exists in the file at once, so nothing stops a rule from reading the close while pretending it’s lunchtime. The data doesn’t know what time it is; only your code does.
Subtler versions are worse:
- Using today’s high to decide whether to buy today. You only know the high after the fact.
- Survivorship: testing on today’s list of companies, which quietly excludes everyone who went bust. Your strategy never had the chance to buy the ones that failed.
- Restated data: economic figures get revised. The version you have now isn’t the version people had then.
How to spot it
The tell is a backtest that’s too good. If a strategy wins 85% of the time, or its equity curve is a smooth line with no ugly stretches, something is probably leaking. Real strategies have miserable months.
The honest test is to ask, for every input the rule reads: at the moment this decision is made, would I actually have had this number? If you’d have had to wait until the close, the bell, or tomorrow’s data release, then the rule can’t have it either.
Paper trading catches this one for free, because live data genuinely arrives one tick at a time and there’s nothing to peek at.