OPEN-SOURCE SCRIPT

Repainting? Yes/No

ที่อัปเดต:
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.

เอกสารเผยแพร่
Just fixed comment
Oscillators

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ