OPEN-SOURCE SCRIPT

Repainting? Yes/No

Atualizado
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 Lançamento
Just fixed comment
Oscillators

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?

Aviso legal