0

I know it's not the most elegant way to handle Support and Resistance values but it's good enough for me, for now.

Here's my code (based on this working answer):

var SupportResistance = array.new_float()
array.push(SupportResistance, 1.29000)
array.push(SupportResistance, 1.29100)

var float SupRes1 = array.get(SupportResistance, 1) // Trying to read a value
line.new(bar_index, close, bar_index, SupRes1, color=color.red, extend=extend.right)

For some reason, this results in vertical red lines, even though I shot the two example values ​​directly close to the real price.

How can we read these values to use them as any numeric variables?

Vendrel
  • 865
  • 9
  • 19

1 Answers1

0

You are using the same value bar_index as x1 and x2. That's why you get a vertical line.

What you need to do is to use bar_index and bar_index + 1 as x1 and x2, and use the same price level as y1 and y2. This would draw a horizontal line.

line.new(bar_index, SupRes1, bar_index + 1, SupRes1, color=color.red, extend=extend.right)
vitruvius
  • 15,740
  • 3
  • 16
  • 26