SourTrade
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: August 13th, 2022

How do you code "dotted lines"?

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.
Last edited by SourTrade on Mon Aug 22, 2022 7:38 pm, edited 1 time in total.

SourTrade
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: August 13th, 2022

Re: How to code "dotted lines"

Does anyone bother to make a reply here? I see a lot of unanswered posts.

ajinc
Pine Script Scholar
Pine Script Scholar
Posts: 2
Joined: May 7th, 2022

Re: How do you code "dotted lines"?

style=plot.style_circles , can be used for plotting dotted lines , Not sure how it can be used for an ema plot.

SourTrade
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: August 13th, 2022

Re: How do you code "dotted lines"?

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.

benjaminbarch
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: December 5th, 2022
Contact: TradingView Profile

Re: How do you code "dotted lines"?

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)

Return to “Pine Script Q&A”