◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Learn / Does Supertrend Repaint? A Deterministic Answer
learn-article

Does Supertrend Repaint? A Deterministic Answer

Supertrend does not repaint on confirmed bars — once a bar closes, the line and its flips are fixed forever — but it does fluctuate on the live bar, and it becomes a genuine repainter when pulled from a higher timeframe through a bare request.security call. This article proves each claim from the indicator's mathematics and shows the correct Pine Script v6 patterns for confirmed-bar signals and non-repainting HTF Supertrend. Educational material only, not financial advice — a non-repainting Supertrend is not a profitable one, and trading carries a real risk of loss.

Does the Supertrend indicator repaint?

No — on confirmed bars. Once a bar closes, Supertrend's line value and direction for that bar are final: they will never be redrawn, and the historical chart shows exactly what a live viewer saw at each close. Yes — on the live bar, where the line and even the trend direction can flip back and forth as ticks arrive, unwinding before the close. And yes — when misused, most commonly by requesting Supertrend from a higher timeframe through a bare request.security call, which makes the value mutate until the higher-timeframe bar completes.

So the one-word answers you find on script pages — both the "it repaints!" warnings and the "non-repainting version!" advertisements — are each half right. The precise statement is: Supertrend is a non-repainting indicator whose signals repaint if you take them from unconfirmed bars. The distinction is between the indicator's mathematics (clean) and the signal pipeline built on top of it (frequently not).

This matters because Supertrend flips are almost always consumed as events — an alert, an arrow, a strategy entry — and events evaluated on a still-forming bar describe trades nobody could have reliably taken. A backtest full of intrabar flips, or an HTF Supertrend that used the forming 4-hour bar, will not match live behaviour, and the discrepancy is routinely misdiagnosed as broker slippage or "market makers."

The rest of this article proves the closed-bar claim from the indicator's construction, shows exactly where the live-bar and higher-timeframe repaints come from, and gives validated Pine Script v6 code for both the confirmed-signal and non-repainting HTF patterns. Educational only — nothing here is financial advice.

Why closed-bar Supertrend cannot repaint

The claim "Supertrend doesn't repaint after the close" is not folklore — it follows from the construction. Supertrend is built from three ingredients, all of which are functions of the current and past bars only.

First, a midpoint: hl2, the average of the bar's high and low. Second, a volatility offset: a multiplier (commonly 3) times ATR (commonly 10 periods), where ATR is Wilder's smoothed average of true range — again, only current and past bars. These combine into two provisional bands: hl2 + factor × ATR above, hl2 − factor × ATR below.

Third, the ratchet, which is what makes Supertrend Supertrend: in an uptrend the active band is the lower one, and it is only allowed to move up (it takes the maximum of its previous value and the new candidate, so long as the previous close was above it); in a downtrend the upper band mirrors this, only moving down. When the close crosses the active band, direction flips and the other band takes over. In Pine v6 this whole construction is the built-in ta.supertrend(factor, atrPeriod), returning the line and a direction series.

Check the construction against the three repaint mechanisms. Lookahead? No term references future bars — nothing like a forward displacement or lookahead_on exists in the formula. Lookback redrawing? The recursion runs strictly forward; no past value is ever reassigned once its bar confirms. Compare ZigZag, whose latest leg is provisional by design — Supertrend has no provisional history at all. Live-bar fluctuation? Yes — hl2, ATR and the close all move intrabar, which is the one honest caveat and the subject of the next section.

Conclusion: on confirmed bars, Supertrend is deterministic and fixed. Anyone claiming otherwise is describing one of the two misuse modes below.

Where it does repaint: the live bar — and your alerts

On the currently forming bar, everything Supertrend depends on is still moving: the high and low can extend (moving hl2), the true range can grow (moving ATR), and the close is provisional. So the line wiggles intrabar — and near the band, the direction itself can flip to up, back to down, and up again within a single bar. If your alert or arrow fires on the first flip, you have acted on a signal that may not exist at the close. That is not the indicator repainting; it is your pipeline consuming unconfirmed data.

The fix is to evaluate flips only on confirmed bars:

//@version=6
// Educational only — validate before trading; not financial advice.
indicator("Supertrend — confirmed-bar signals", overlay = true)

atrLen = input.int(10, "ATR length", minval = 1)
factor = input.float(3.0, "Multiplier", minval = 0.1)

[st, dir] = ta.supertrend(factor, atrLen)

plot(dir < 0 ? st : na, "Up trend",   color = color.green, style = plot.style_linebr)
plot(dir > 0 ? st : na, "Down trend", color = color.red,   style = plot.style_linebr)

flipUp   = ta.change(dir) < 0
flipDown = ta.change(dir) > 0

plotshape(flipUp and barstate.isconfirmed, "Flip up",
     style = shape.triangleup, location = location.belowbar, color = color.green)
plotshape(flipDown and barstate.isconfirmed, "Flip down",
     style = shape.triangledown, location = location.abovebar, color = color.red)

if flipUp and barstate.isconfirmed
    alert("Supertrend flipped up (confirmed bar)", alert.freq_once_per_bar_close)
if flipDown and barstate.isconfirmed
    alert("Supertrend flipped down (confirmed bar)", alert.freq_once_per_bar_close)

Details that matter: ta.supertrend returns direction as negative in an uptrend, so a flip to up is ta.change(dir) < 0. Every signal — shapes and alerts alike — carries the and barstate.isconfirmed gate, and the alerts use alert.freq_once_per_bar_close as a second layer of the same discipline. The cost is honest: you see the flip one bar-close later than an intrabar gambler would. The benefit is that your chart history, alert log, and backtest all describe the same events.

The higher-timeframe trap: Supertrend through request.security

The second genuine repaint is the popular "4-hour Supertrend on a 15-minute chart" setup. Fetch it naively and you have built a repainting indicator out of a non-repainting one:

// ❌ Wrong — repaints: the forming 4H bar's Supertrend mutates until it closes
[stBad, dirBad] = request.security(syminfo.tickerid, "240", ta.supertrend(3.0, 10))

Why this fails: the expression is evaluated on the higher timeframe, and the current 4-hour bar is still forming for up to sixteen 15-minute bars. During that window, the returned line and direction track the live HTF bar — flipping and unflipping — while historical chart bars display only the final, settled value. Live behaviour and history disagree, which is the definition of repainting. (Adding barmerge.lookahead_on without an offset is strictly worse: historical bars then receive the HTF close before it existed — a lookahead leak that makes backtests look clairvoyant.)

The correct pattern requests the last confirmed higher-timeframe value — offset the tuple by one HTF bar and keep lookahead off:

//@version=6
// Educational only — validate before trading; not financial advice.
indicator("HTF Supertrend — non-repainting", overlay = true)

atrLen = input.int(10, "ATR length", minval = 1)
factor = input.float(3.0, "Multiplier", minval = 0.1)
htf    = input.timeframe("240", "Higher timeframe")

[stRaw, dirRaw] = ta.supertrend(factor, atrLen)

// [1] + lookahead_off = last CONFIRMED higher-timeframe values only
[stHtf, dirHtf] = request.security(syminfo.tickerid, htf,
     [stRaw[1], dirRaw[1]], lookahead = barmerge.lookahead_off)

plot(dirHtf < 0 ? stHtf : na, "HTF up",   color = color.green, style = plot.style_linebr)
plot(dirHtf > 0 ? stHtf : na, "HTF down", color = color.red,   style = plot.style_linebr)

The delay this introduces — up to one full HTF bar — is not a flaw. It is the information a live trader actually had. If your strategy only works without the delay, it was trading the leak.

"Non-repainting Supertrend" scripts — and what no-repaint doesn't mean

Search results for this question are dominated by TradingView script pages advertising "non-repainting Supertrend." Now you can evaluate that pitch precisely: standard Supertrend already doesn't repaint on confirmed bars, so a "non-repainting version" is either (a) simply gating signals on bar close — one barstate.isconfirmed clause you have already seen, not a new indicator; (b) fixing an HTF request with the [1] + lookahead_off pattern — likewise a two-token fix; or (c) marketing attached to an unrelated modification. There is no secret formula, and any script whose selling point is "no repaint" should survive the checks below before it earns trust.

Verify any Supertrend variant empirically in minutes. Bar Replay: step through history and confirm flips appear only at bar closes and never vanish afterwards. Alert-log reconciliation: run the flip alert live for a few days, then check every alert has a matching chart arrow and vice versa — intrabar-gated scripts fail this immediately. Static check: look for signals not gated on barstate.isconfirmed, and any request.security lacking the [1] offset with barmerge.lookahead_off — the exact patterns ForexCodes' free Repaint Checker flags automatically, with the offending line numbers.

Finally, calibration — because "non-repainting" is routinely sold as if it implied "profitable." It does not. A correctly gated Supertrend still whipsaws in ranging markets by construction: the flip is the lagging response to a move that already happened, and sideways price action generates flip after flip, each surrendering a band-width of adverse movement. Repaint-correctness means your backtest honestly describes signals that existed; whether those signals carry any edge after spreads, slippage and the multiplicity of parameter choices you tried is a separate question that most tests fail. Educational only; not financial advice. Trading carries a real risk of loss.

Key takeaways

Educational only — not financial advice. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro