First: I'm pretty sure this is my poor understanding of how things work ??
I'm trying to plot a a "solid channel" with two horizontal straight lines as the upper and lower limits (red lines), and two straight horizontal lines that mark the first and the forth "forths" of the range between the upper and lower limits (the blue lines).
I was able to plot them. The problem is: I'd like to have only the last instance of these lines in the screen (based on the lookback period), but most of the time there are many of them.
Below you can see the code. And below the code, you can see in the first screenshot what I expect, and in the second and third screenshots you can see how it usually looks like.
Question is: how can I always have only one instance (the latest one) of this channel in the screen (i.e. only the four expected lines, two red and two blue)?
Any help will be highly appreciated! Cheers!
lookBack = 24
range = 4
highestHigh = highest(high, lookBack)
lowestLow = lowest(low, lookBack)
xAxisStartAt = bar_index[lookBack]
xAxisFinishesAt = bar_index
uppperLimit = highestHigh
lowerLimit = lowestLow
upperRange = ((highestHigh - lowestLow)/range) + lowestLow
lowerRange = highestHigh - ((highestHigh - lowestLow)/range)
// PAINTBRUSH
line.new(xAxisStartAt, uppperLimit, xAxisFinishesAt, uppperLimit, color=color.red, width= 3, extend=extend.none)
line.new(xAxisStartAt, lowerLimit, xAxisFinishesAt, lowerLimit, color=color.red, width= 3, extend=extend.none)
line.new(xAxisStartAt, upperRange, xAxisFinishesAt, upperRange, color=color.blue, width= 1, extend=extend.none)
line.new(xAxisStartAt, lowerRange, xAxisFinishesAt, lowerRange, color=color.blue, width= 1, extend=extend.none)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…