OPEN-SOURCE SCRIPT

Repainting? Yes/No

Actualizado
Suppose, you'd like to avoid repainting issues in your scripts. How to achieve this?..

If you do not use `security` function, then simply calculate only on confirmed (closed) bars. Use either `close[1]` as a source or/and `barstate.isconfirmed` variable in your logic.

But if you use `security` to get data of a higher timeframe, then what? In such a case to get the same result - use `security` with
* `lookahead` param switched ON
* in `expr` param use "square brackets of 1" - previous bar value of your signal (`data` variable is your "signal").

NOTE 1: that `gaps` param doesn't affect repainting in any way.
NOTE 2: `lookahead` param when switched OFF affects the `security` behaviour only on history data. And indicator still repaints (realtime calculations change after chart reload).

In my example, script uses 5 minute closed bars (that means they will not change after chart reload, so there will be no repainting) on 1 minute chart.
Plots that "repaint" are hidden. You may make them visible to see how they look like.

Notas de prensa
Just fixed comment
Oscillators

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad