PineScript Labeling Specific High Value on Chart

Viewed 33

Dear Friends, Please find below the sample code to LABEL the specific high values (like NNN9.90 eg 59.90 , 349.90 , etc) on chart. It is observed that label is not getting displayed on the occurrence of desired HIGH value... Please Help.

please find sample code below

    //@version=5
    indicator('TEST1', overlay=true, scale=scale.right, max_labels_count=500 ) 
    // PLOTTING High value line nnn9.90
    var hln = 0.0
    hln := (high + 0.10) % 10 == 0 ? high : na
    plotshape(hln, color=color.new(color.blue, 0), style=shape.triangledown, 
text='WP',size=size.tiny)
if hln > 0
        label.new(bar_index, na, str.tostring(high,format.mintick) + '\n  ', 
loc=yloc.abovebar, style=label.style_none, textcolor=color.yellow, size=size.normal)

End of code.

1 Answers

It is working for me

//@version=5
indicator('TEST1', overlay = true, scale=scale.right, max_labels_count=500 ) 
// PLOTTING High value line nnn9.90
var hln = 0.0
hln := (high + 0.10) % 10 == 0 ? high : na
plotshape(hln, color=color.new(color.blue, 0), style=shape.triangledown, text='WP',size=size.tiny)
if hln > 0
    label.new(bar_index, high, str.tostring(high,format.mintick) + '\n  ', yloc=yloc.abovebar, style=label.style_none, textcolor=color.yellow, size=size.normal)

Related