/ Check 6 · Repaint

Does my TradingView indicator repaint?

If a signal can appear, move or vanish after the bar it sits on has closed, the indicator repaints, and its backtest was scored on information nobody had at the time. You can find out without reading the strategy logic.

The short answer

An indicator repaints when the value it shows for a past bar is not the value it showed on that bar while it was live. History is computed from finished candles; the live bar is computed from a candle that is still forming. When the two disagree, the chart you scroll back through is cleaner than the one you would have traded, and so is any backtest run on it. The most common cause in Pine Script is a single line that pulls a value from a higher timeframe.

A worked example: a daily filter on a 15-minute chart

A strategy trades a 15-minute chart and only takes longs when price is above a daily EMA, requested with request.security(syminfo.tickerid, "D", ta.ema(close, 12)).

  • On history, with Pine's default lookahead_off, each 15-minute bar reads the last finished day. The filter only changes when a day closes.
  • Live, the same call reads the day that is still forming, so the filter moves with every tick. A long can trigger mid-session on a filter value that the finished day later contradicts. Reload the chart and that trade is recomputed from the finished day, and may no longer be there.
  • Turning lookahead on without an offset breaks it the other way: on history, the first 15-minute bar of each day receives that day's final value, a close nobody could know at 00:15. That backtest is reading the future.

The version that holds up asks for the last closed day inside the call, ta.ema(close, 12)[1] with lookahead = barmerge.lookahead_on, so history and the live bar receive the same confirmed value. The cost is lag: in a market that trades 24 hours a day, one daily bar spans 96 fifteen-minute bars, so the filter can be up to 96 chart bars old before it updates. The full explanation, with both broken versions, is in the one-bar repaint note.

How far behind the honest filter can be

The lag is one higher-timeframe bar, counted in chart bars. For a market that trades 24 hours a day:

  • Daily value on a 15-minute chart: 1,440 ÷ 15 = 96 bars.
  • Daily value on a 1-hour chart: 1,440 ÷ 60 = 24 bars.
  • 4-hour value on a 1-hour chart: 240 ÷ 60 = 4 bars.

If a strategy's results look much better with the filter than a value that old could plausibly explain, the filter is probably not the honest version.

Three checks, cheapest first

1. Read the requests. Search the script for request.security. For each call, check that the series is offset by [1] inside the call and that lookahead is on. An offset outside the call shifts by one chart bar, not one higher-timeframe bar, and does not fix it.

2. Run the reload test. Screenshot the signals on a live chart, wait for at least one higher-timeframe bar to close, reload, and compare. Any signal that moved was computed from a candle that had not closed.

3. Watch it live before you trust the history. Leave the indicator on a live chart for a session and note where signals appear in real time. If the history later shows signals in places you never saw them, the backtest is scoring trades you could not have taken.

See it on your own chart

There is no calculator for this one; the tool is a chart. The free, open-source Repaint Demo: Higher-Timeframe EMA, Both Ways plots the same daily EMA the repainting way and the honest way side by side. Leave it on a live 15-minute chart for a few hours, then reload. The other checks have calculators on the tools page.

This is check 6 of 10

The one-page Backtest Verification Checklist, free. Confirm the email and the PDF opens straight away; one worked check each Tuesday after that.

How these numbers were worked out

The only figures here are bar counts: minutes in the higher-timeframe bar divided by minutes in the chart bar, for a market that trades 24 hours a day (a day is 1,440 minutes, a 4-hour bar 240). Markets with shorter sessions have fewer chart bars per day. The EMA and its length are an example, not a recommendation, no strategy result is quoted, and nothing here is investment advice.

Historical simulations are not live results. Nothing on this site is investment advice.