◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Guide · correctness

What is repainting?

A signal that shows up on the live (still-forming) bar, then changes or disappears once the bar closes. Your backtest counts trades that never really happened.

Where it comes from

The usual culprit: a signal computed on the current, unconfirmed bar with no barstate.isconfirmed gate. The crossover can flip back and forth until the bar finally closes.

//@version=6
indicator("EMA cross", overlay=true)
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
buy = ta.crossover(fast, slow)   // can appear, then vanish before close
alertcondition(buy, "Buy")

The fix

Gate the signal so it only locks in on a closed bar. It arrives one bar later — that's the honest trade-off, not a downgrade.

buy = ta.crossover(fast, slow) and barstate.isconfirmed

Other repaint sources: higher-timeframe request.security read without a [1] offset, and calc_on_every_tick=true strategies.

Catch it automatically

Not sure if your indicator repaints? Paste it into the ForexCodes Validator — it flags the missing confirmation that causes repainting.

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

Catch the bug that compiles.Run auditGet Pro