0

Getting error when attempting to plot new line using created variables for x1,y1,x2,y2 parameters.

//instantiates peaks from which first line is to be drawn
highest_peak = ta.highest(close,20)
highest_bar = bar_index[highest_peak]
//instantiates dips from which second line is to be drawn
lowest_dip = ta.lowest(close,20)
lowest_bar = bar_index[lowest_dip]

//instantiaties average between peaks and dips
split_difference = (highest_peak + lowest_dip)/2
barshift_split = bar_index[split_difference]

//plots the two lines
line.new(highest_bar, highest_peak, barshift_split, split_difference)
line.new(lowest_dip, lowest_bar, barshift_split, split_difference)

Have tried to use historical operator to limit x1 and y1 to a minimum of 2 bars back. No change. have commented out the lines and simply plotted the variables highest_peak, lowest_bar, split_difference. They are able to plot successfully. Have tried adding an if statement before line.new with the condition that the bar index-x1 is less than 1000. No change.

I'd like to be able to automatically draw two lines that intersect at the split_difference point based on the high, low and average 20 bars back. Thanks for the help.

0 Answers0