OPEN-SOURCE SCRIPT

Repainting? Yes/No

Aktualisiert
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.

Versionshinweise
Just fixed comment
Oscillators

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Haftungsausschluss