Skip to content

Research notes

Crypto backtest look-ahead bias: audit the signal clock

A correct average can create an impossible trade. Follow three candle closes through an availability clock and a reproducible causality check.

Diverging lime and paper paths illustrate crypto backtest look ahead bias.
Illustration for research notes; examples in this article are educational.

Crypto backtest look-ahead bias occurs when a decision uses information that had not yet become available. The fastest practical check is to rerun the same frozen rules on progressively truncated data: adding tomorrow's rows should not change yesterday's finalized inputs or signals. This test needs an explicit availability clock, because a candle timestamp alone does not say when its final value was knowable.

A price series can be authentic and the backtest still be impossible. The error may be a join, a full-column average or a higher-timeframe value assigned to an earlier decision. Reviewing profit after the fact will not reveal which input crossed that boundary.

Put four times beside one signal

For each field used by a strategy, distinguish its event time, publication time, receipt time and decision time. Event time labels the market interval. Publication time says when the source released the observation. Receipt time says when the particular system obtained it. Decision time is when the strategy evaluated its rule. Historical archives often provide only the first of these.

A one-hour candle labeled 12:00 might represent the hour beginning at 12:00. Its final close is unavailable at 12:15 even though its label is earlier than the decision. Likewise, a feature calculated from the eventual daily high cannot justify a morning entry. Decide how the archive labels intervals before comparing timestamps.

TradingView distinguishes changes on an unconfirmed realtime bar from behavior that leaks future values into historical decisions. Its repainting documentation also explains why higher-timeframe inputs can differ between historical and realtime calculations. The useful question is which value was available at the decision, rather than whether every changing indicator is defective. TradingView's repainting documentation

A useful audit row therefore includes the source interval, finalization condition, expected arrival delay, decision timestamp and earliest executable order timestamp. Keep each as a separate field. A chart marker does not replace that record.

A three-candle example that exposes the leak

The following dataset is invented for this explanation. It is not a KLINEO replay or a recommended trading rule. Assume hourly candles are labeled by their opening time, close exactly at the next hour, and arrive two seconds later. The strategy may act only after receipt.

Candle label, UTCFinal closeFinal close first usableMean of all three final closes
12:00$10013:00:02$104
13:00$10214:00:02$104
14:00$11015:00:02$104

The last column is (100 + 102 + 110) / 3 = 104. It is arithmetically correct. Using that value at 13:00:02 is causally wrong: two of its three observations are not available yet. At that instant, the available average is $100. At 14:00:02, it is (100 + 102) / 2 = $101.

Suppose an entry rule asks whether the latest available close is below its expanding mean. At 14:00:02, the leaked comparison says $102 < $104, so it enters. The past-only comparison says $102 < $101, so it does not. No execution-cost adjustment repairs the fabricated decision. The feature itself must change, and the historical performance must then be recomputed.

This is a specific failure mode documented by Freqtrade: unwindowed aggregation over a populated historical dataframe can include future candles. Its look-ahead analysis compares outputs from modified backtests to help expose changing indicator values and signals. That describes a diagnostic available in Freqtrade, not a feature claim about KLINEO. Freqtrade look-ahead analysis

Do not simply replace every whole-column mean with a rolling mean and declare the audit finished. A past-only rolling calculation can still use an unfinished candle. Conversely, an expanding mean can be causal if it includes only observations received before the decision. The dependency and timing are what matter.

Run a prefix test before interpreting the chart

Freeze the strategy version, parameters, inputs, timezone and deterministic settings. Run through a chosen cutoff, save all finalized feature values and decisions, and record the exact input file checksum. Then append later records and run again without changing anything else.

Compare only the earlier period whose inputs were already final at the cutoff. Its feature values and decisions should remain unchanged within declared numerical tolerances. Exclude genuinely provisional observations from this invariant and keep their revision policy explicit. Otherwise a legitimate data revision can look like a coding leak, or a leak can hide behind a vague claim that data changes.

A small worksheet makes the test inspectable:

Frozen cutoffEarlier decision inspectedPrefix featureExtended-data featureFinding
14:00:0214:00:02Mean $101Mean $104Later rows changed a finalized input
14:00:0214:00:02Latest close $102Latest close $102This field passed this comparison
14:00:0214:00:02No entryEntryDecision changed because the mean leaked

These rows continue the invented example. A passing comparison does not establish that the whole strategy is free of leakage. Repeat at cutoffs that exercise every entry branch, exit branch, instrument change and feature refresh. If a rule never triggers, this test has not tested its triggered behavior.

Keep the first mismatching intermediate value, not just the final trade count. It directs the investigation toward a feature, a join or a state dependency. Changing all rules simultaneously can remove the symptom without identifying its cause.

Inspect joins, labels and fitting separately

A join can attach a later observation to an earlier row even when every indicator calculation is past-only. In a constructed example, a sentiment release has an event date of Tuesday but arrives Wednesday at 09:00. Joining by Tuesday's date alone gives Tuesday's strategy a Wednesday fact. Preserve availability timestamps and use an explicitly backward, availability-aware match.

Machine-learning pipelines add another boundary. A scaler fitted on the full dataset lets the training period learn the range or distribution of later observations. A model trained to predict a future return legitimately uses that future return as a training label; it must not receive that label, or an indirect transformation of it, as a live input. Track feature generation, label generation and model fitting as distinct operations.

For an overlapping forward-return label, the training row may start before the evaluation boundary but finish after it. Removing only rows whose start date lies inside the test period does not necessarily remove the overlap. The walk-forward testing guide develops this boundary with a dated example.

Also inspect universe selection. Choosing today's surviving coins for a backtest years earlier uses later knowledge even when every price feature is causal. That is the separate problem covered in survivorship bias and historical universes.

Tell a repaired test from a verified strategy

After finding a leak, rerun the frozen research protocol using causal features. Preserve the original result as a rejected run and identify the correction. If the repaired result is much weaker, that is useful evidence. Restoring the old profit by tuning on the same evaluation period turns the repair into a new selection exercise.

Record which fields were tested, how many branches triggered and which cutoffs were compared. Freqtrade explicitly notes that its diagnostic can miss signal types that did not trigger, and some strategy behavior can create false positives. A diagnostic result is scoped evidence, not a universal certificate. Freqtrade diagnostic caveats

A helpful disposition uses three categories. Reject a run whose decisions demonstrably use unavailable values. Investigate a run whose timing or revision policy cannot be reconstructed. Retain a run for further evaluation when the tested dependencies are causal and the evidence is reproducible. Retaining it does not mean it is profitable, executable or suitable for a particular account.

Execution remains another layer. A signal generated after the close cannot automatically fill at that same close, and a candle touching a limit does not establish a fill. The broader crypto backtest evidence review separates those modeling questions from information leakage.

What to request from a backtest author

Ask for one reconstructed signal with its full input lineage. A useful response contains the data interval, availability timestamp, feature version, fitting window, decision time and order eligibility time. It also identifies whether the source was revised and whether the historical file preserves the originally available version.

If only event timestamps exist, say that availability was modeled rather than observed. An assumed delay can support a sensitivity test, but it cannot reconstruct a missing release log. Increase the assumed delay and report whether the decision changes. That is a concrete uncertainty a reader can assess.

For KLINEO's published simulations, start with the declared inputs and boundaries in the backtest methodology. Do not infer that an unrelated engine, an AI-generated explanation or a new workflow has inherited those checks. Review the exact saved workflow and its Virtual, testnet or Live context separately.

Method and limits

This AI-assisted article combines the linked primary software documentation with original timing examples and an original audit worksheet. The three closes, two-second delay and signal rule are hypothetical; their means and comparisons were independently recomputed. No KLINEO strategy, historical market dataset or production order was tested. Passing a causality check removes one reason to distrust a simulation; it does not establish future returns or remove the risks described in the trading risk disclosure.

Keep the context with the example.

Prepared with AI assistance by KLINEO Editorial. Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.