Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Pinescript 5 uniqueid of a bar

Jan 31, 2023 - 2:59 PM

Viewed 1380 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/1627292 COPY
  • Dear All,

    I am learning pinescript 5 on tradingview platform. I a novice developer. Need guidance of the forum members.

    The script is to create label the bar. This part I have completed that when a condition is satisfied the bar is labeled as anchor above the bar.

    However when new candles are presented another condition is checked, if this condition is satisfied then the old lable of anchor is to be deleted and new label is to be created above the same bar POI.

    The 2 problems I am facing is

    • In the first condition check the candle is identified as high[3] and after condition check the label is printed above high[3]. After new candles are presented and after second check how to refer to that same candle? is there a unique id for a bar which can be used?

    • How to identify the existing label anchor above that bar, delete the existing label and then stamp a new label by referring to the bar.

    I hope I have been able to explain. English is not my native language.

    Thanks.

    0
  • 1) You can use the bar_index variable which is a candle unique id
    2) not sure to understand but you'll find some examples here: https://www.tradingview.com/pine-script-reference/v5/#fun_label{dot}delete

    0
CONTENTS