I've been working with Pine Script for many years now & lately been working on building quite a complex strategy which combines various different indicators. I like to think I've figured out all of the ways strategies can repaint, however for some reason after months of live testing I now got an alert which shouldn't have fired. As you can see in the screenshot, an alert fired during last bar's close, however no signal showed. I'm working with a 3D timeframe and not using any lower or higher timeframe inputs.
One of the ways to test for repainting, which is actually the biggest headspinner, is that no signal shows up either when trying the Replay function. Using the Replay function, you can see price action as it played out in real-time. This should show a signal showing up during the replay and disappear when the replay is over in the case of repainting. However, that did not happen.
Also important to note is that I've used 4 anti-repaint methods in my script when using the security function:
- Using previous close with barmerge.lookahead_on:
H_close = request.security(symbol, res, close[1], lookahead=barmerge.lookahead_on) - For alerts I've set frequency to once per bar close:
alert("Long, Ticker: (" + str.tostring(syminfo.ticker) + "), Price (" + str.tostring(close) + ")", alert.freq_once_per_bar_close) - And for entry/exit conditions using barstate.isconfirmed
ExitLongPos = exit_long and barstate.isconfirmed - All securities are in the same timeframe
So even though the strategy has been working as expected for months now and this is possible just some weird outlier, I still want to make sure I'm not repainting. Has anybody had something similar? Or maybe has a suggestion to fix such alerts? Perhaps implementing a delay before giving an alert or something?
Any help would be great! Thanks :)