Page 1 of 1

How do you code "dotted lines"?

Posted: Sat Aug 13, 2022 4:50 am
by SourTrade
Being a color blind, I'm more used to differentiating lines by their shape than color. So I would like to code one of the lines as a "dotted line". For example, plot EMA20 as a solid line and EMA50 as a dotted line.

As simple as this might be, I just can't find any resource on this. In the official Pine Script documentation, there is a mention about "hline.style_dashed" but I get an error when I include this in the PLOT function. Any suggestion would be appreciated.

Re: How to code "dotted lines"

Posted: Thu Aug 18, 2022 4:42 am
by SourTrade
Does anyone bother to make a reply here? I see a lot of unanswered posts.

Re: How do you code "dotted lines"?

Posted: Fri Oct 07, 2022 3:44 am
by ajinc
style=plot.style_circles , can be used for plotting dotted lines , Not sure how it can be used for an ema plot.

Re: How do you code "dotted lines"?

Posted: Fri Oct 14, 2022 5:11 am
by SourTrade
ajinc wrote:
Fri Oct 07, 2022 3:44 am
style=plot.style_circles , can be used for plotting dotted lines , Not sure how it can be used for an ema plot.
Thanks for the reply. Man, this place is surely buzzing with quick answers. :wink:

Anyway, back to your response, although I haven't included it in the code, I think this only works for lines you draw like trendlines and horizontal lines. I don't think it applies to moving averages.

Re: How do you code "dotted lines"?

Posted: Tue Dec 06, 2022 5:21 pm
by benjaminbarch
The plot.style_circles seems to plot as a dotted line ok. Try something like this.

Code: Select all

//@version=5
indicator("Dotted EMA5")


inputColor = input.color(title="My Colored Line", defval = color.blue)
whatImPlotting = ta.ema(close, 5)

plot(whatImPlotting, style=plot.style_circles, color=inputColor)