7

Trying to plot a normal serie line but with the V4 of pine script I can't find how to set the style?

This gives me an error :

plot(my_serie, color=color.blue,linewidth=2, style=line.style_dashed)

Any help appreciated.

Idris
  • 600
  • 2
  • 4
  • 16

2 Answers2

14

There is no dashed style for plot(). This turns the color on and off to achieve the effect:

plot(my_serie, color=bar_index % 2 == 0 ? color.blue : #00000000, linewidth=2)
PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
  • This works. But the dash line drawn this way doesn't look like the original hline dashed line unfortunately. – Steeve Nov 14 '19 at 14:42
  • Thanks for this precious information. You are absolutely right. Our apologies; we should of course have warned potential users that this is a workaround which they should stay away from if they require precisely the same look as that produced by `hline`, which doesn't plot series. – PineCoders-LucF Nov 14 '19 at 18:53
  • 1
    In the latest version of Pine (v4), use `n` instead of `bar_index`: `color=n % 2 == 0 ? blue : #00000000` – Marcel Nov 28 '20 at 08:31
  • 1
    That's incorrect. In Pine v1 to v3, `n` was the equivalent of what is now `bar_index` in v4. – PineCoders-LucF Jan 04 '21 at 22:43
-4

Use the below -

Change the end part based on your requirement, set

style=plot.style_dashed

Jeff Mergler
  • 1,384
  • 20
  • 27
Ganesh
  • 1