What is look-ahead bias in a backtest?
Look-ahead bias is any use, at the moment a simulated trade is decided, of information that a trader standing at that bar could not have had. The rule is not wrong; the test is asking it a question with the answer attached.
The reason it is so damaging is that the leak is never neutral. Random noise in a test hurts and helps in roughly equal measure. Future information only helps, because it is by definition correct about what happened next. A small leak therefore produces a consistent, believable upward bias rather than the obvious nonsense that would get caught.
It is also silent. Nothing throws an error when a moving average is computed over a window that includes the current bar's close, or when a swing high is marked on the bar where it occurred rather than the bar where it became identifiable. The equity curve simply looks better than it should, and the person who built the test has no reason to doubt it.
This is why the defect belongs at the top of any checklist. Overfitting produces a result that fails out of sample. A leak can pass an out-of-sample test too, because the leak is present in both halves of the data.
Where does the future leak in?
The future leaks in through five doors: the forming bar, higher-timeframe values, indicators that recompute, structure that is only confirmed later, and data that was revised after the fact.
The forming bar is the most common. A rule that reads the current bar's close and enters at the current bar's open has looked ahead by exactly one bar. On a daily chart that is a whole session of information. The fix is mechanical, decide on the closed bar and act on the next open, and it is astonishing how many hand-built harnesses do not do it.
Higher-timeframe values leak the same way with a larger window. A four-hour indicator sampled during the second hour of that bar is reading a value that will not exist for another two hours. The correct value is the last completed four-hour bar, and using anything else means every intraday decision knows part of the afternoon.
Indicators that recompute earlier values as new data arrives are a subtler case. Centred averages, some smoothing methods and any pivot-detection routine that revises history will show a clean historical series that never looked that clean at the time. A chart of the finished indicator is not the indicator the trader would have seen.
Structure and revised data close the list. A swing high needs several bars to the right before it is a swing high at all, so marking it on the bar it occurred imports those bars. Adjusted price series, restated economic figures and corrected ticks all rewrite the past, and a test run on the corrected version is running on data nobody traded.
How do you detect look-ahead bias?
The direct test is to shift every input one bar later and rerun; if the result collapses, the strategy was living on the bar it just lost. Three other checks catch the cases a shift does not.
The first is reconstruction. Take a single historical trade and rebuild the decision by hand using only bars up to and including the one before the entry. If any input to the rule cannot be reproduced from that window, the test leaked. This is tedious and it is the only method that finds every kind of leak, so it is worth doing on a handful of trades from any strategy that looks unusually good.
The second is a plausibility check on the numbers. A rule with a modest logic and a very high win rate, or a profit factor far above anything similar strategies achieve, is more likely to be leaking than to be exceptional. The prior for exceptional is small.
The third is replay. Step through the same period bar by bar in a tool that only reveals data as it arrives and take the trades the rule specifies. Where the replay trades and the backtest trades diverge, the divergence is either a leak or an execution assumption, and both need to be found.
Why is it so hard to remove from a hand-built harness?
A hand-built harness leaks because the convenient way to write almost every step is the leaking way, and nothing in the language pushes back.
Vectorised code is the usual culprit. Computing an indicator over the whole series and then indexing into it is fast and readable, and it makes the current bar's value available at the current bar, where the rule reads it a bar early. The leak-free version has to lag every derived series by one, and any series built from that series, and any comparison between them.
Structure detection compounds the problem. A function that returns the list of swing highs in a series will return the one that occurs on the bar being decided, because that bar is in the input. Every consumer of the list then knows the future. Making it correct requires the function to know which bar is being decided and to withhold anything not yet confirmed at that bar, which is a different and more awkward design.
The practical consequence is that a harness written in an afternoon should be assumed to leak somewhere until a reconstruction check says otherwise. That is not a criticism of the author. It is what the default tools do.
How does QuantParadox guard against it?
QuantParadox reads every input, including structure, swings and ranges, as of the bar being decided, and any higher-timeframe value it supplies is the last completed bar of that timeframe rather than the one still forming.
That as-of discipline is what makes the pattern-based rules testable at all. A swing high is not reported until the bars that confirm it have closed, which means the platform marks it later than a chart drawn by eye would. Some patterns look worse under that treatment than they do in a textbook, and that is the honest version of the pattern rather than a flaw in the grading.
The guard is at the data boundary, and it is worth being clear about what that does not cover. It grades a rule on what could have been known; it cannot tell you the rule is good. A strategy graded leak-free can still be overfitted, undersized or unprofitable after costs, and each of those has its own check.
Where the platform cannot resolve something honestly it says so rather than guessing. That is the same principle as the intrabar rule for stops and targets, and it exists because a backtest that fills gaps in its knowledge with favourable assumptions is a backtest that is looking ahead by another name.