Reputation: 137
I have a line in pine script called Total. Now I need to create a line in the opposite direction of the Total line movement. I do not mean -Total. I mean that for example when Total line starts from 0 to 100, at the same time the new line starts from 100 to 0. How can I generally create this line from the first candle on the chart?
Upvotes: 0
Views: 47
Reputation: 21342
Just swap the x1
and x2
parameters.
//@version=6
indicator("My script", overlay=true)
left = bar_index
right = bar_index + 100
if (barstate.islast)
l1 = line.new(x1=left, y1=high, x2=right, y2=low, color=color.green)
l2 = line.new(x1=right, y1=high, x2=left, y2=low, color=color.red)
Upvotes: 1