Pinescript Calculating 3rd point by joining 2 existing points from previous bar. i.e projecting trends

18 views Asked by At

I am trying to project a trend through points on the chart. I have 2 set of points(lets say highs of 2 previous candles).If I draw a trendline through those 2 points, it will be extended right to the current bar. Is there a way for me to calculate what the value will be on the 3rd bar without having to actually plot the line.

I am currently doing it this way and this doesnt feel very optimized.

tLine = line.new(bar_index - 2, high[2], bar_index - 1, high[1], width = 0, color=color.black, extend=extend.right, style = line.style_dotted)

plot(tLine.get_price(bar_index), "highs", color.orange, 2, plot.style_circles)
tLine.delete()
0

There are 0 answers