I'm trying to allow for the manual deletion (or change of coordinates) of lines in an array through an manual input. when I plot the 'array.size' function, it shows the array size as 14, however when I try to turn off any of the lines in the array except the first (index = 0) it gives me this error: "In 'array.get()' function. Index 1 is out of bounds, array size is 1." Code:
var line [] line_array= array.new_line ()
if m_sr
line_supres = line.new (m_time, m_sr, (m_time+1), m_sr, xloc.bar_time, extend.right, color.green)
array.push (line_array, line_supres )
if (barstate.isrealtime == false) //confirmed
line.set_color (line_supres, color.purple)
if (tf_supres1 == false)
line.set_y1 (array.get (line_array, 0), 0)
line.set_y2 (array.get (line_array, 0), 0)
if (tf_supres2 == false)
line.set_y1 (array.get (line_array, 1), 0)
line.set_y2 (array.get (line_array, 1), 0)
if (tf_supres3 == false)
line.delete (array.get (line_array, 2))
if (tf_supres4 == false)
line.delete (array.get (line_array, 3))
if (tf_supres5 == false)
line.delete (array.get (line_array, 4))
if (tf_supres6 == false)
line.delete (array.get (line_array, 5))
if (tf_supres7 == false)
line.delete (array.get (line_array, 6))
if (tf_supres8 == false)
line.delete (array.get (line_array, 7))
if (tf_supres9 == false)
line.delete (array.get (line_array, 8))
if (tf_supres10 == false)
line.delete (array.get (line_array, 9))
if (tf_supres11 == false)
line.delete (array.get (line_array, 10))
if (tf_supres12 == false)
line.delete (array.get (line_array, 11))
if (tf_supres13 == false)
line.delete (array.get (line_array, 12))
if (tf_supres14 == false)
line.delete (array.get (line_array, 13))
if (tf_supres15 == false)
line.delete (array.get (line_array, 14))
if barstate.islast
label.new (bar_index, 0, "Array Size: " + str.tostring (array.size(line_array)))
Here are some plot screen shots:
1.) Plot with no lines turned off
2.) Plot with line 1 turned off (correctly changed coordinates to the 0 line)
3.) Plot with line 2 turned off (breaks chart with the error message for any lines 2-last)
Thanks so much in advance!