I have an issue with my script. It is generating alot of Labels in the same location. I think the issue is the "y" variable, but I dont know how to connect it with my input bar location.
Script:
// Input I used | Time
barTime = input.time(title="Bar Time", defval=timestamp("01 Jan 2022 13:30 +0000"), confirm=true)
// Label
SL_label = label.new(
x = barTime,
y = close,
text= trailType == "Long" ? "Long T" : "Short T",
color = trailType == "Long" ? color.green : color.red,
style = trailType == "Long" ? label.style_label_up : label.style_label_down,
textcolor = color.white,
xloc = xloc.bar_time)
It is because you never delete your label.
Add this to the end of your script and it will plot one label.
label.delete(SL_label[1])