Reliability guide
Reduce Pine Script repainting and lookahead bias.
Learn how completed-bar execution and restricted cross-context requests reduce common Pine Script repainting and lookahead-bias risks.
Why a historical result can look too good
A strategy should only act on information that was available at the simulated decision time. Historical results become unreliable when code uses a future value, an unfinished live bar, an unconfirmed higher-timeframe value, or an order state that cannot be reconstructed from ordinary OHLC bars.
Closed-bar calculations
The public backtesting environment evaluates strategy logic once per completed chart-timeframe bar. A signal that appears briefly during a live bar but disappears before the close is not treated as a confirmed historical signal.
Prices can change; no confirmed historical decision yet.
OHLC values become the confirmed input for strategy logic.
Market, stop, and limit orders follow the recorded OHLC broker-emulation settings.
Why cross-context requests are restricted
Multi-timeframe requests are not inherently invalid. However, reproducing their confirmation timing, alignment, historical coverage, and lower-timeframe behavior consistently requires additional data and execution semantics. The public compatibility environment therefore rejects the entire multi-timeframe surface instead of approximating it.
- Higher- and lower-timeframe requests, whether confirmed or unconfirmed
- Lower-timeframe arrays used to reconstruct activity inside a bar
- Cross-symbol data whose alignment and availability differ from the chart
- Tick-by-tick recalculation on an unfinished live bar
- Immediate recalculation after a simulated order fill
What these restrictions do not guarantee
Restricted execution reduces common repainting and lookahead paths, but it cannot guarantee identical results everywhere. Exchange feeds, historical revisions, trading sessions, missing bars, dataset coverage, rounding, and fill rules can still create differences. A strategy can also be overfit even when it never repaints.
Read the execution model to distinguish completed-bar calculation timing from stop, limit, market, and on-close fill behavior.
Reliability checklist
- Confirm the script uses
strategy(), not onlyindicator() - Use one chart timeframe and avoid cross-symbol requests
- Record commission, slippage, dates, sessions, and input values
- Keep a separate validation period that was not used to design the rules
- Compare the exact script and settings when another engine produces a different result