Pine Script look-ahead checker

Paste Pine Script to locate potential higher timeframe look-ahead patterns. The static scan runs in your browser. The pasted script is not sent to a server.

Check a script

The synthetic example below requests a daily close with lookahead_on and no expression history offset. It produces an alert.

Result

potential look-ahead risk

  1. Line 3: security() with lookahead_on and no explicit expression history offset can leak higher timeframe values into historical bars.

    request.security(syminfo.tickerid, "1D", close, lookahead=barmerge.lookahead_on)

    Possible false positives: Same or lower timeframe requests, an offset inside a helper or intermediate variable, or a non-price expression can require manual review.

What the alert means

On historical bars, lookahead_on can place a higher timeframe value before that value was available. TradingView documents a history offset on the requested expression, such as close[1], for earlier higher timeframe values.

The default lookahead_off avoids that historical future leak, although values can still change on realtime bars. barstate.isconfirmed does not work inside request.security().

The scanner recognises direct expression offsets and tuples with an offset on each member. It does not trace wrapper calls, intermediate variables, arrays or request.security_lower_tf. Timeframe relationships and script execution are not evaluated. A result of “no pattern matched (static scan, partial recall)” is not a validation of the strategy. Review the look-ahead bias guide and Pine Script backtest validation before interpreting a backtest.

TradingView documentation, read 2026-10-03: other timeframes and data, repainting, and bar states. Pine v1/v2 security() used the older lookahead behavior; the scanner alerts on those calls when the version directive is present.

Frequently asked questions

Does an empty result mean the script is free of look-ahead?

No. The scan has partial recall and cannot establish how a script behaves when Pine executes it.

Does a result mean my backtest is biased?

The alert identifies a pattern for manual review. Same or lower timeframe requests and expressions resolved through variables can change the interpretation.

Is my pasted code uploaded?

The checker reads the textarea in the browser and makes no request with its contents. Do not put the script in a shareable page URL.