0
votes

I would like to allow users of my script to display or hide some dashed horizontal lines.

I can't find the way to do this using hline.

I've managed to do it using plot, but there is no dashed line format for plot. (I know there is a trick to plot dash lines: How to plot a dashed line on pine script V4?, but the end result doesn't look like the original hline dash line.)

2

2 Answers

0
votes
//@version=4
study("")
showHline = input(true)
hline(50, color = showHline ? color.blue : #00000000)
plot(na)
0
votes

You can increase the transparency of the color to 100 based on your conditions to show/hide the line

transparency = condition ? 100 : 0
yourLine = hline(50, "Zero",color=color.new(color.black, transparency))

define condition to derive transparency as per your requirements