How can I draw a horizontal line at the price level when my condition is triggered ? (version#4)
plotshape(crossUp_red ? rvi : na, title="Up Arrow", style=shape.arrowup, location=location.abovebar, color=#109c3f, size=size.small, text="crossUp_red") // plots arrow
However I'm having trouble plotting a line at the price where 'crossUp_red' is triggered.
trigger_price = valuewhen(crossUp_red, close, 0)
plot(trigger_price, title="line_crossUp_red", color=color.green, linewidth=2, transp=0)
Draws line/all lines, but amassed at the bottom of the chart.
trigger_price = valuewhen(crossUp_red, close, 0)
hline(trigger_price, title="Trigger Price", color=color.red, linestyle=hline.style_dotted)
Error: Cannot call 'hline' with 'price'=series[float]. The argument should be of type: input float
Many thanks.
You can use line.new()
for this.
if (crossUp_red)
red_line = line.new(bar_index, rvi, bar_index + 1, rvi, extend=extend.right)
This will draw a line and extend it to the right whenever crossUp_red
is true
. The line will be at rvi
's value. I don't know if it is price or not. If you want, you can change rvi
to close
then it would draw it at that bar's close price.
If you want to delete some lines in the future, you can use the line.delete()
function.