Look-Ahead Bias in Crypto Backtests, With Examples

Look-ahead bias lets a backtest use data it could not have known. See seven real examples in crypto backtests and two simple tests that catch them.

Trigr Research6 min read
On this page
  1. What is look-ahead bias?
  2. Which look-ahead leaks come from timing?
  3. Which look-ahead leaks hide in the data?
  4. Which look-ahead leaks come from research choices?
  5. How can you detect look-ahead bias?
  6. How does Trigr guard against look-ahead bias?
  7. Next steps

TL;DR: Look-ahead bias is when a backtest lets a decision use information that did not exist yet at the moment of that decision. In crypto it usually hides in multi-timeframe indicators, same-bar fills, whole-sample normalization, and data that is timestamped at its reference date instead of its release date. Delaying signals by one bar and truncating the data are two cheap tests that expose most leaks.

What is look-ahead bias?

A backtest is a simulation that walks forward through history. Look-ahead bias is any path by which the simulation, standing at time t, peeks at something from after t. The result is a strategy that trades on knowledge nobody had.

The bias is dangerous because it is rarely dramatic. A leak of one bar can turn a random strategy into a steady winner, and the code that causes it often looks correct at a glance. The principle that prevents it is point-in-time backtesting: every feature at a bar is computed from what was knowable at that bar's close.

Below are seven concrete examples, grouped by where the leak comes from: timing, the data itself, and research choices.

Which look-ahead leaks come from timing?

The first group of leaks comes from using a price or value before the moment it existed.

Example 1: filling at the close that created the signal

A strategy computes RSI on the 4H close and buys when RSI crosses above 30. The backtest records the entry at that same close price.

The problem is timing. The close is only final when the bar ends, and by then you can no longer trade at it. Any order you send goes in at the next available price. Assuming the signal-bar close biases results toward whatever the close happened to be, and on bars where a sharp move happens right at the end, that bias is systematic. The honest default is to fill at the next bar's open, covered in detail in next-bar-open fills.

Example 2: higher-timeframe indicators on lower-timeframe bars

This is the most common leak in multi-timeframe strategies. A 1H strategy filters trades with "daily close above the 50-day moving average." The researcher resamples to daily, computes the moving average, and joins it back onto the hourly bars by date.

Every hourly bar on a given day now sees that day's final close, which is only known at midnight UTC. At 03:00 the strategy already knows how the day ends.

In pandas the fix is a one-bar shift on the higher timeframe before joining, so each hour sees the last completed daily value. The DataFrame.shift documentation covers the mechanics:

daily = hourly["close"].resample("1D").last()
ma50 = daily.rolling(50).mean()

# Leaky: each hour sees the current day's final value
# hourly["ma50"] = ma50.reindex(hourly.index, method="ffill")

# Point-in-time: each hour sees the last *completed* day
hourly["ma50"] = ma50.shift(1).reindex(hourly.index, method="ffill")

The same issue applies to cross-asset inputs, such as reading a BTC regime signal on an ETH strategy. Trigr carries coarser and cross-asset inputs forward from their last completed value and never reads ahead.

Example 3: reading the order of events inside a candle

A breakout strategy enters when price exceeds the prior high and exits at a take-profit 2% above entry. The backtest checks whether the bar's high reached the take-profit and books a win.

But a candle does not record the order of events. If the low also breached the stop-loss, you do not know which came first. Assuming the favorable order is a quiet form of look-ahead. Trigr replays 5-minute candles inside an ambiguous bar when the strategy's timeframe is coarser than 5 minutes, and if that still cannot decide, the stop wins.

Which look-ahead leaks hide in the data?

The second group comes from how data is prepared and stamped, often before the strategy logic even runs.

Example 4: normalizing with the whole sample

A feature is z-scored using the mean and standard deviation of the full history. Or a funding-rate signal fires when funding is in the "top 10% of all observations."

Both thresholds are computed with data from the future. In 2021 the strategy knows what the funding distribution will look like in 2024. The fix is to compute these statistics on a rolling or expanding window that ends at the current bar. The same rule applies to machine learning scalers: fit them on training data only.

Example 5: data stamped at its reference date, not its release date

Many datasets carry two timestamps: the period an observation describes, and the moment it was published. Using the first when you should use the second is look-ahead.

Dataset Reference date Actually knowable
CFTC Commitments of Traders Tuesday After the Friday afternoon release
Monthly CPI The month it measures Roughly mid-way through the following month
Revised macro series The original release Only the first published value was knowable then
Perp funding The settlement time After that settlement, not before

The CFTC states that its COT report is generally published on Friday using data from the preceding Tuesday. The St. Louis Fed's ALFRED archive keeps each historical vintage of FRED series, because revised values differ from what traders saw at the time.

On Trigr, API data series carry the time each value became available, and a bar only sees values available at or before its close. FRED series use first-release values from ALFRED, stamped at the date they were first published, and weekly COT data carries a fixed, conservative six-day publication lag. You can see which sources are available in the live data catalog.

Which look-ahead leaks come from research choices?

The last group has nothing to do with code. It comes from decisions the researcher makes with hindsight.

Example 6: choosing the universe with hindsight

"Backtest a momentum strategy on the top 20 coins" sounds neutral. If the top 20 is today's list, the backtest excludes every coin that collapsed and includes coins that were small when the test starts. This is survivorship bias, a close relative of look-ahead bias.

The same thing happens informally when you pick an asset for a backtest because you remember it performed well. The safest habit is to decide the universe and the rule for selecting it before looking at results, and to be suspicious of any strategy that only works on the assets that rallied.

Example 7: overlapping labels in machine learning

In ML strategies, a label often describes what happens over the next several bars. If a training sample's label window overlaps the test period, the model has effectively seen part of the test answers. López de Prado's remedy is to purge overlapping samples and add an embargo between train and test, which we explain in purged walk-forward validation.

Trigr's ML optimization uses point-in-time features with a loader that raises an error on future leakage, and each run returns a leak verdict with flags.

How can you detect look-ahead bias?

Two tests catch most leaks, and neither needs special tooling.

  • The delay test. Shift every signal one bar later and rerun. A real edge usually degrades gradually. A leak often collapses outright, because the strategy was profiting from the bar it should not have seen.
  • The truncation test. Run the feature pipeline on data that ends at some date T, then on the full data. Every signal up to T must be identical. If adding future data changes past signals, something reads ahead.

Also watch for results that are too clean: very high win rates on short holds, a nearly straight equity curve, or a Sharpe ratio far above what similar strategies achieve. Those are not proof of a leak, but they justify the two tests above.

How does Trigr guard against look-ahead bias?

Trigr treats point-in-time behavior as the default, not an advanced setting, so a strategy built in the no-code graph or drafted by an AI assistant is held to the same rules:

Leak Trigr's default
Same-bar fills Signals fill at the next bar's open
Higher-timeframe and cross-asset inputs Last completed value carried forward, never read ahead
Release lags Values joined on when they became available, not the date they describe
Intrabar ordering 5-minute replay when the timeframe is coarser, then the stop wins; a stop gapped through fills at the worse open
Missing data Never filled with invented values; the signal waits
ML features The loader raises an error on future leakage, and each run returns a leak verdict

None of this protects you from research choices such as picking assets with hindsight. Those still depend on discipline.

Next steps

Take a multi-timeframe strategy you have already tested and run the delay test on it before anything else, or compare it with published strategies that carry verified backtests in the Trigr marketplace. For the full set of conventions that keep a backtest honest, read our pillar guide on point-in-time backtesting or the backtesting docs.

Frequently asked questions

What is look-ahead bias in a backtest?

Look-ahead bias happens when a backtest uses information at a given moment that was not yet available at that moment, such as a candle that had not closed or a data point that was published later. It makes results look better than anything you could have traded.

How do I check a backtest for look-ahead bias?

Two quick tests catch most cases. Rerun with every signal delayed by one bar and see whether performance collapses, and rerun on data truncated at an earlier date to confirm the signals up to that date do not change.

Can multi-timeframe strategies have look-ahead bias?

Yes, it is one of the most common sources. If a 1-hour strategy reads a daily indicator, it must use the last completed daily bar until the current day closes; otherwise every hour of the day sees that day's final close.

Does Trigr prevent look-ahead bias?

Trigr computes every feature only from information available at the bar's close, carries coarser and cross-asset inputs forward instead of reading ahead, and fills at the next bar's open. Its ML loader also raises an error if a feature row would come from the future.

Put the idea to an honest test.

Describe a strategy in plain English or from your own AI assistant, backtest it on point-in-time data, and forward-test it on paper before any real money is involved.