The following script creates a label for each element of the series. How can one create a label only on candles with corresponding not NaN values?
//@version=5
indicator('Print text values', overlay=true)
length = input(2)
up1 = ta.pivothigh(high, length, length)
l = label.new(bar_index-length, high, str.tostring(up1))
>Solution :
There is actually a na() function to test if the value is na.
So, you can do the following.
//@version=5
indicator('Print text values', overlay=true)
length = input(2)
up1 = ta.pivothigh(high, length, length)
if not na(up1)
l = label.new(bar_index-length, high, str.tostring(up1))
