2021-08-30

How can I set label location in Pine Script so its on the line and not above or below it?

I want the value to be placed on the line and not below bar. How do I do that? I only see abovebar and belowbar in pine-script manual. Above and below is making my chart look very messy.

if isBullEngulf
bullEngulfOpen := line.new(bar_index - 1, open[1], bar_index, open[1], extend=extend.right, color=color.black)
bullEngulfLow := line.new(bar_index - 1, low < low[1] ? low : low[1], bar_index, low < low[1] ? low : low[1], extend=extend.right, color=color.green)
bullEngulfLowPrice = line.get_y1(bullEngulfLow)
offset                  =       input(15, maxval=900, title="Label Offset",step=5)
tl                      =       offset *(time - time[1])
bullEngulfLowLabel := label.new(x = t1 + time, y = na, text="\n"+tostring(bullEngulfLowPrice), style=label.style_none,size=size.normal,textcolor=color.white, yloc=yloc.belowbar)
//bullEngulfLowLabel := label.new(x = bar_index, y = na, text="\n"+tostring(bullEngulfLowPrice), style=label.style_none,size=size.normal,textcolor=color.white, yloc=yloc.belowbar)
bullEngulfHigh := line.new(bar_index - 1, high < high[1] ? high : high[1], bar_index, high < high[1] ? high : high[1], extend=extend.right, color=color.green)
bullEngulfHighPrice = line.get_y1(bullEngulfHigh)
bullEngulfHighLabel := label.new(bar_index - 1, high[1],text="\n"+tostring(high[1]),
 style=label.style_none,size=size.normal,textcolor=color.white, yloc=yloc.abovebar)

enter image description here



from Recent Questions - Stack Overflow https://ift.tt/2WAEl8p
https://ift.tt/3jqIvsz

No comments:

Post a Comment