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.
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")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.
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.