'How to prevent a plot from the past repainting?

Is there a way to prevent a plot that has already appeared from erasing itself shortly after? I'm using pinescript on TradingView and an indicator sometimes does this. I'm aware it is due to security() and lookahead_on, and that repainting in the code should be avoided entirely, but I'd like to experiment with just making sure the plot itself is permanent when it appears, irrespective as to whether the code tells it to erase itself. Thanks for any help



Solution 1:[1]

It's hard to tell without seeing your code.

For security() you can use the following function:

f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)

For other cases, you can use the barstate.isconfirmed built-in variable together with your other conditions that feeds the plot(). barstate.isconfirmed will be true with the last update of the bar. So, in that caase, the price action would be confirmed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vitruvius