0

I am coding long short entry exit conditions and trying to plot shapes on TradingView chart based on those conditions, but I need to use custom location rather than the inbuilt location options. I particularly need to move the shapes on the Y axis to change their vertical positions. How can I do so with pine script?

I have tried the following, but it didn't worked -

var label longconditionlabel = na

if longcondition
    longconditionlabel := label.new(bar_index, low, style = label.style_triangleup, color = color.green)
    label.set_y(longconditionlabel, low * 0.75)

var label shortconditionlabel = na

if shortcondition
    shortconditionlabel := label.new(bar_index, low, style = label.style_triangledown, color = color.red)
    label.set_y(shortconditionlabel , high * 0.75)

1 Answers1

1

I would just set the Y location when you create the label. Here's an example. In the image attached, I have this code on there twice. Once with the Y set to low * 0.95 and the second instance Y is set to low * 0.75 You can see the different placements

longcondition = open > open[1] and open[1] > close[1]
var label longconditionlabel = na
if longcondition
    longconditionlabel := label.new(bar_index, low * 0.95, style = label.style_triangleup, color = color.green)

enter image description here

smashapalooza
  • 932
  • 2
  • 2
  • 12