The rule that prevents it is simple to state and easy to break: at every step, a backtest may only use data that existed before the order would have been sent. If a rule needs a candle's close, the trade can only happen after that candle has closed. If a rule needs a figure published after the market shuts, the trade can only happen the next day. Most look-ahead bias comes from code or spreadsheets that line up data by date without asking at what time each number became known.
Look-ahead bias at a glance
| Mistake | What goes wrong | Fix |
|---|---|---|
| Trading at the close of the signal candle | The signal needs the close, so the trade cannot also fill at that close | Fill at the next candle's open, or later |
| Using the day's high, low or close in an intraday rule | These are known only after the close | Use only candles that have already closed |
| Using indicators that look forward | Some smoothing methods, such as a centred average, use later prices | Use indicators calculated from past values only |
| Using swing points before they are confirmed | A swing high is known only after the candles that follow it | Act only once the swing is confirmed |
| Using end-of-day data for intraday decisions | Daily IV, open interest and settlement prices come after the close | Use intraday snapshots, or trade the next day |
| Using today's lot sizes or expiry rules on old data | Contract rules change over time | Use the rules in force on each date |
| Using revised or adjusted data | Corporate actions and index changes are applied later | Use data as it stood on each date |
| Using today's index members | Shares that left the index are missing | Use the members as they were on each date |
A short history of the problem
Researchers met look-ahead bias long before retail traders did. In the 1980s, academic studies of share returns often matched each company's accounting figures to its share price on the date of the financial year end, even though the accounts were published weeks or months later. In 1986 Rolf Banz and William Breen showed that such data could produce results that no investor could have earned, because the figures were not known when the trades were assumed to happen.1 The fix they argued for, using data as it stood on each date, became standard practice, and commercial "point-in-time" databases were built to supply it.
A related problem, choosing what to test after looking at the data, was set out by Andrew Lo and Craig MacKinlay in 1990 under the name data snooping.2 Practitioners added their own list of everyday timing errors as computing made backtests cheap: trades at the signal candle's close, stops placed using the day's full range, and indicators that quietly use future values.
Indian traders face an extra version of the problem because the rules of the market have changed so often since 2024. SEBI's measures of 1 October 2024 ended weekly expiries on all but one index per exchange and raised contract sizes; the NSE moved its expiries to Tuesday from 1 September 2025 and changed lot sizes again from 31 December 2025.34 A backtest that applies today's contract rules to every past date is using information from the future too.
When Indian market data becomes known
Every number in a backtest has two dates: the date it describes and the moment it became known. Look-ahead bias lives in the gap between them. For common Indian market data, the gap looks like this:
| Data | Describes | Known from |
|---|---|---|
| A 5-minute candle's open, high, low and close | 9:15 to 9:20 am, for example | 9:20 am, when the candle closes |
| The day's high, low and close | The whole session | After the market closes |
| Futures settlement prices and the exchange's daily price files | The whole session | After market hours |
| Provisional FII and DII cash market figures | The whole session | In the evening, after the close |
| India VIX | Each moment of the day | Live through the day; its closing value only at the close |
| Company quarterly results | A quarter that ended weeks earlier | The moment they are filed with the exchange, often during or after market hours |
| Index member changes | A later effective date | Announced weeks before they take effect |
| Lot size and expiry changes | A future series | Announced by circular, usually well ahead |
The habit that prevents most errors is to store both dates for every number, and to let a rule use a number only after its "known from" time.
Example: an opening range breakout
An opening range breakout strategy buys when Nifty futures trade above the high of the first 15 minutes, from 9:15 to 9:30 am.
- Correct: the opening range is known at 9:30. A breakout can only be acted on after that, and the order fills at the next available price.
- Biased: the code uses the high of the 9:15 to 9:30 window but checks for a breakout from 9:15 onwards. Early in the window, the strategy is trading against a high that has not happened yet.
The biased version catches moves it could never have caught live. The fix is a time check: no signal before 9:30.
Example: filling at the signal candle's close
A rule buys one lot of Nifty futures (65 units) when a 15-minute candle closes above its 20-period exponential moving average.
- Biased: the backtest buys at the close of the signal candle, the very price that created the signal.
- Correct: the backtest buys at the open of the next candle, the first price a live order could get.
Suppose the next candle opens on average 4 points above the signal close after an upward break. Over 120 trades, the biased test has quietly given the strategy 4 × 65 × 120 = ₹31,200 of entry price it could never have had. If the strategy's whole edge in the biased test was ₹30,000, it had no edge at all.
Example: a stop placed with the day's low
A rule buys Nifty futures at 10:00 am at 25,100 and places its stop just below "the day's low".
- Biased: the backtest takes the day's low from the daily candle, 24,980, which was not reached until 2:00 pm. The stop sits 120 points away and is never hit, and the trade ends in profit at 3:15 pm.
- Correct: at 10:00 am, the day's low so far was 25,040. A stop just below it, at 25,040, is hit at 11:30 am for a loss of 60 × 65 = ₹3,900.
One timing choice turned a ₹3,900 loss into a winning trade. Repeated over many days, it can turn a losing rule into a "proven" one.
Example: a filter that is only known at the close
A trader tests a rule that sells one lot of the at-the-money Nifty straddle at 9:30 am on expiry day, a Tuesday. To avoid big moves, the rule adds a filter: trade only on days when Nifty's range from high to low stays under 0.8%.
The filter sounds sensible, but the day's range is known only after the close. Suppose the test covers 60 expiry days. On 38 of them the range stayed under 0.8%, and the straddle kept an average of 50 points. On the other 22, the market moved and the straddle lost an average of 95 points before its stop.
- Biased test: the filter lets through only the 38 quiet days. Profit: 38 × 50 × 65 = ₹1,23,500 before charges.
- What live trading would have done: at 9:30 am nobody knows which days will be quiet, so the rule trades all 60. Result: (38 × 50) − (22 × 95) = −190 points, or −₹12,350 before charges.
The filter did not reduce risk; it removed the losing days after the fact. An honest version replaces it with something known at 9:30, such as the size of the first 15 minutes' range, and must then be tested again from scratch, because that filter will let through some bad days and block some good ones.
Look-ahead bias in options backtests
Option data adds its own traps:
- Choosing strikes with end-of-day prices. A rule that sells the strike nearest ₹100 premium at 9:20 am must use 9:20 prices, not the day's settlement price.
- Expiry dates. Bank Nifty had weekly expiries until November 2024, and the NSE moved expiries to Tuesday from September 2025. A backtest must use the expiry calendar in force on each date; our Nifty expiry date calendar lists the current ones.
- Lot sizes. Nifty's lot was 75 from November 2024 and has been 65 since 31 December 2025. Applying one lot size to the whole history misstates profit and margin.
- Implied volatility. IV calculated from the closing price cannot drive a morning entry.
- Greeks. A rule that picks the strike with a delta of 0.30 at 9:30 am needs the delta as it stood at 9:30, from the prices of that minute.
- The ATM strike. "At the money" depends on the index price at the moment of entry, not on the day's close or the next day's open.
Look-ahead bias in indicator and price action rules
- Repainting indicators. Standard indicators such as moving averages, RSI and MACD do not change their past values once a candle has closed. Some tools do: zigzag lines, some pivot and swing-point markers, and indicators that use a centred window. A backtest built on them sees each turn more clearly than anyone could have at the time.
- Unconfirmed swing points. A swing high is usually defined as a candle higher than the two before and the two after it. It is known only two candles later. A backtest that acts on it on the candle itself is looking ahead.
- Multi-timeframe rules. A rule on 15-minute candles that also checks "the daily trend" must use the daily candle as it stood at that moment: yesterday's close, or today's candle so far, never today's final close.
Look-ahead bias in share-selection rules
Strategies that pick shares from a list have three more traps:
- Index membership. A test of "the Nifty 50" over ten years using today's members leaves out the companies that dropped out, usually after doing badly, and includes ones that joined after doing well.
- Corporate actions. After a share splits 1-for-5, adjusted price history shows the old prices divided by five. A filter such as "only shares priced above ₹500" applied to adjusted prices selects shares that were never in that range at the time.
- Results and announcements. A rule that buys "companies with rising profits" must use results only from the day they were announced, not from the end of the quarter they describe.
Where it hides in spreadsheets
Many Indian traders test ideas in Excel or Google Sheets before using software. Spreadsheets make look-ahead bias easy because every cell can see every other cell. The usual culprits:
- A formula that points one row down. If prices are listed oldest first, a formula in row 50 that reads row 51 is reading the next candle. This often happens after copying a formula from a sheet laid out newest first.
- Sorting after the formulas are written. Sorting a sheet by date, newest first, can turn every "previous candle" reference into a "next candle" reference without any warning.
- MAX and MIN over the whole day. A cell that finds "the day's high" by looking at all of the day's rows gives every row, including the 9:20 am row, the high reached at 2:00 pm.
- Looking up daily data by date. A lookup that pulls the day's closing VIX, the evening's FII figures or the settlement price into each intraday row hands the morning rows numbers from the evening.
- Averages over the whole column. A rule such as "buy when RSI is below its average" that uses the average of the whole test period tells each trade something about the years that follow it.
A quick test for any spreadsheet: delete the last month of data. If any number in the earlier months changes, something in the sheet is reading the future.
Where it hides in code
Code that uses data tables, such as Python's pandas library, has its own versions of the same errors:
- Shifting the wrong way. Moving a column by one row to compare "this candle with the last one" is easy to do in the wrong direction, which compares it with the next one instead.
- Building larger candles from smaller ones. When 1-minute candles are combined into 15-minute ones, the result may be labelled with the start time, 9:15, while it contains prices up to 9:29. A rule that trades "at 9:15" on that candle has seen the next 14 minutes.
- Centred rolling windows. A rolling average set to sit in the middle of its window uses as many future candles as past ones.
- Joining daily data to intraday rows. The same lookup problem as in spreadsheets: a join on the date alone gives every minute of the day that day's closing values.
- Scaling or choosing settings on the whole data set. Calculating a mean and standard deviation, or picking the best stop, over all the data before splitting it into test periods lets the early trades benefit from later data. Choose settings on the earlier part and test them on the later part.
The same "delete the last month" test works for code: run the backtest with and without the final month and compare every trade before it. They should be identical.
How to check a backtest for it
- Read the trade log. For each of a dozen trades, confirm that every input was known before the entry time.
- Delay the entries. Shift every entry by one candle. A small change in results is normal; a collapse suggests the strategy relied on information it could not have had.
- Look for results that are too good. Very high win rates, tiny drawdowns, or entries at the exact low of the day are warning signs.
- Check the timestamps of every data source. Ask when each number became available, not only which date it belongs to.
- Test on live prices. A forward test uses prices as they arrive, so look-ahead bias cannot occur in it. Compare its results with the backtest over the same weeks.
Our guide to backtesting mistakes covers the other errors that make backtests look better than live trading.
What the one-candle delay test looks like in numbers
The delay test in step 2 is the quickest check most traders can run, so it helps to know what a normal result looks like. Take two strategies, each tested over 200 trades on Nifty futures:
| Strategy A | Strategy B | |
|---|---|---|
| Profit as tested, before charges | ₹1,20,000 | ₹2,40,000 |
| Profit with every entry one candle later | ₹1,02,000 | −₹18,000 |
| Change | 15% lower | Profit gone |
Strategy A gives up some profit, as expected: entering later means entering at a slightly worse price. Its edge survives. Strategy B's whole result depended on entering at a price it could only have known in hindsight. The bigger and smoother the original result, the more suspicious a collapse like this should make you.
The test is not proof in either direction. A strategy that trades fast moves may lose more than 15% to a one-candle delay without any bias, and a biased strategy may survive the delay if the future information it uses is several candles ahead. It is a first check, done before the slower one of reading the log.
A worked example: finding the bias in a trade log
A trader's spreadsheet backtest of a Bank Nifty option-buying rule shows 68% winning trades and a smooth equity curve. The rule: buy an at-the-money call when the 5-minute candle closes above the previous day's high, with a stop at 30% of the premium.
The trader checks five trades by hand:
| Trade | Signal candle close | Entry price used | First price a live order could get | Stop based on |
|---|---|---|---|---|
| 1 | 10:05 | Premium at 10:05 close | Premium at 10:05 + next tick | Entry premium |
| 2 | 11:40 | Premium at 11:40 close | Next candle's open | Entry premium |
| 3 | 9:20 | Premium at 9:20 close | Next candle's open | Entry premium |
| 4 | 13:15 | The day's lowest premium | Next candle's open | Entry premium |
| 5 | 10:50 | Premium at 10:50 close | Next candle's open | Entry premium |
Trade 4 is the problem: a formula error took the option's lowest premium of the whole day as the entry price. Searching the sheet shows the same formula on about a fifth of the trades. Corrected, the win rate falls to 51% and the rule loses money after costs. Five minutes of reading the log saved real money.
Rebuilding a biased backtest honestly
Finding the bias is half the job. Fixing it without creating a new one takes some care:
- Write the rule as a timeline. For each step, note the clock time: "at 9:30 the opening range is known; from the 9:30 candle onwards, a close above it is a signal; the order goes out at the next candle's open."
- Replace every hindsight input. The day's low becomes "the low so far"; the day's closing VIX becomes "VIX at the entry minute"; this quarter's results become "the last results announced before today".
- Use the contract rules of each date. Lot sizes, expiry days and trading hours as they stood on the day of each trade.
- Re-run the test and keep the old result beside it. The gap between them is the size of the bias. Do not adjust the settings until the new result looks like the old one; that only swaps look-ahead bias for overfitting.
- Run the delay test again. An honest rule should now lose only a modest share of its profit to a one-candle delay.
- Test it forward. A few weeks on live prices, with test money, shows whether the honest backtest is close to what the market actually gives.
If the honest result is poor, the rule had no edge; the biased test only hid that. Dropping it early costs nothing, while trading it live would cost real money.
Why it slips through
Look-ahead bias survives because nobody checks results they like. A backtest that loses money gets examined line by line; one that makes money gets shared. The error also hides well: the code runs, the numbers add up, and each trade looks plausible on its own. Only the timing is wrong, and timing does not show up in a profit total.
Three habits catch most cases. Treat any result that looks better than expected as a bug until proven otherwise. Write down, for every input to a rule, the moment it becomes known. And have someone else read a sample of the trade log, because the person who wrote the rule tends to see what they meant rather than what the code does.
Related biases
- Overfitting: settings fitted to the noise of one period. See our guide to avoiding overfitting; walk-forward testing is the main check.
- Survivorship bias: testing only instruments that exist today.
- Selection bias: reporting only the best of many tests.
- Ignoring costs: leaving out brokerage, STT and slippage.
How QuantPower's backtests avoid it
QuantPower is trading software; its backtests are built to use only data that existed at each moment:5
- Rule backtests act only on closed candles, from 5-minute to daily, read from your broker's own candle history, up to 2,000 candles a run. A position opens at the closed candle's price adjusted for your slippage setting, and stops and targets are checked on the candles that follow.
- Option strategy backtests step through each trading day minute by minute. At the entry time, each leg picks its strike from the index price at that minute; every minute after that, each leg is checked against its own stop and target and the strategy against its overall limits; whatever is open closes at the exit time.
- No invented data. If the broker has no candles for the period, the test says "Data is not available" and stops.
- Signals decide on closed candles too, from 1 minute to 1 week, so live alerts and orders follow the same timing as the tests.
Then run the strategy in Forward test, on live prices with test money, before going live.
Start with 500 free tokens
Connect your broker, build a strategy and test it on paper before a single live order goes out.
Where the fight against look-ahead bias is going
Data is getting finer and faster, which makes timing errors easier to make and harder to see. A test on tick data or minute data can mix up the order of events within a second as easily as a daily test once mixed up the order of days. The answer is the same as it was in 1986: data stamped with the time it became known, and software that refuses to use a number before that time. As AI assistants write more strategies and backtests, that refusal needs to be built into the tools rather than left to the person writing the rule.
Contract rules will keep changing as well. Indian index derivatives have seen new lot sizes, new expiry days and new trading hours within two years, and each change adds another date that a long backtest has to respect. Expect more testing tools to store contract rules by date, so that a test of 2024 uses 2024's lots and expiries automatically.
Frequently asked questions
What is look-ahead bias in simple words?
A backtest that uses information from the future. For example, a rule that buys at 10:00 am using that day's closing price.
Why does look-ahead bias make results look better?
Because the strategy appears to know what will happen next, it avoids losing trades and enters at better prices than it could in real time.
How is look-ahead bias different from overfitting?
Look-ahead bias is a timing error in how data is used. Overfitting is choosing settings that fit past noise. A backtest can have both.
Can a forward test have look-ahead bias?
No. A forward test runs on live prices as they arrive, so the future is not available to it.
Do candlestick patterns cause look-ahead bias?
Not if the test waits for the pattern's last candle to close. A pattern that needs three candles is known only when the third one closes; acting on it during the third candle is looking ahead.
How much can look-ahead bias add to a backtest's profit?
There is no typical figure. A small timing slip, such as filling at the signal candle's close, may add a few points per trade. A filter that uses the day's range or close can turn a losing rule into a winning one, as the straddle example above shows. The only way to know is to remove the bias and test again.
Does testing on daily candles avoid look-ahead bias?
No. Daily tests have the same trap one level up: a rule that uses today's close cannot trade at today's close, and a rule that uses today's high cannot place an order at today's open. Fill at the next day's open, or use only yesterday's candle.
Can a broker's candle data cause look-ahead bias?
The candles themselves record what happened, so they do not. The risk is in how a test uses them: the time each candle is labelled with, and whether a candle that is still forming is treated as closed.
Related guides
- Backtesting mistakes: the other errors that flatter a backtest
- Backtest performance metrics: reading the report once the test is honest
- Backtesting: rule and option strategy backtests in QuantPower
References
- R. W. Banz and W. J. Breen, "Sample-Dependent Results Using Accounting and Market Data: Some Evidence", *Journal of Finance* 41(4), 779–793 (1986)
- A. W. Lo and A. C. MacKinlay, "Data-Snooping Biases in Tests of Financial Asset Pricing Models", *Review of Financial Studies* 3(3), 431–467 (1990)
- SEBI, circular "Measures to strengthen Equity Index Derivatives framework for increased investor protection and market stability", 1 October 2024 (sebi.gov.in)
- NSE, circulars on the revision of expiry days (from 1 September 2025) and lot sizes of index derivatives (from 31 December 2025) (nseindia.com)
- QuantPower: backtest engines and signal timing, from the app's code, checked 12 November 2026