I tried using label.delete function:
if (longsignal and showpos)
l3 = label.new(time + 10*dt, low, xloc=xloc.bar_time, text = 'SL='+tostring(longsl), color=#02ad09, style=label.style_labelup, textcolor=color.white, size=size.normal)
label.delete(l3[1])
But i have this error:
Undeclared identifier 'l3'
I even tried to add ":= "after "l3" instead of a "=" but stil get different error:
Mismatched input 'l3' expecting 'end of line without line continuation'.
I suspect it has to do with IF condition i used before label creation.... :(
You are declaring the variable in the local scope, this could cause the issue.
In the example below the label variable is declared in the global scope, then use :=
to re-assign the value in the local scope.
var label l3 = na
if (longsignal and showpos)
l3 := label.new(time + 10*dt, low, xloc=xloc.bar_time, text = 'SL='+tostring(longsl), color=#02ad09, style=label.style_labelup, textcolor=color.white, size=size.normal)
label.delete(l3[1])