0

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.)

Dharman
  • 30,962
  • 25
  • 85
  • 135
Steeve
  • 72
  • 10

2 Answers2

0
//@version=4
study("")
showHline = input(true)
hline(50, color = showHline ? color.blue : #00000000)
plot(na)
PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
  • And now I would like to add a condition for the display of hline. I've tried this `code` Cond = Value>100 hline (100, color = Cond ? #A62A4E : #00000000)`code` But it doesn't work. Any help would be greatly appreciated! – Steeve Nov 29 '19 at 14:54
  • You already have a condition in the supplied code, which you select through the script's Settings/Inputs. An hline cannot be turned on for some bars and off for others, like a `plot()` can. – PineCoders-LucF Nov 29 '19 at 15:41
0

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

Swanidhi
  • 2,029
  • 1
  • 20
  • 21