If you searched for "hline.style_dashed" pine script, you probably hit one of two walls: your dashed line shows up solid, or your script throws an error. Both have the same root cause — using the constant in the wrong place. This page is the working reference: minimal code, the styles compared, and the most common mistake.
The minimum working example
Here is a Pine Script v5 indicator that draws three horizontal levels — solid, dashed, and dotted — at fixed prices. Copy it directly into the TradingView Pine Editor:
//@version=5
indicator("hline styles demo", overlay=true)
solidLine = hline(close * 1.01, "Solid", color=color.aqua, linestyle=hline.style_solid, linewidth=1)
dashedLine = hline(close * 1.00, "Dashed", color=color.green, linestyle=hline.style_dashed, linewidth=1)
dottedLine = hline(close * 0.99, "Dotted", color=color.red, linestyle=hline.style_dotted, linewidth=1)
Three lines, three styles, all built-in constants. The dashed line is the one most traders want for VWAP-anchored levels, ORH/ORL markers, prior day high/low — anywhere you want the level visible but visually subordinate to live price action.
hline() only accepts a numeric or input.float() value as its first argument. It cannot take a series — you cannot pass close alone, only constants or input values. If you need a dashed line tied to a moving series (like a 9 EMA), use line.new() for fully programmatic levels.
The three hline styles, side by side
Pine Script gives you three line styles for hline(), all under the hline. namespace. The names are case-sensitive and must be referenced exactly:
hline.style_solid
A solid unbroken line. Default if you omit the linestyle argument entirely.
hline.style_dashed
Evenly-spaced dashes. The most readable secondary-level style.
hline.style_dotted
Tight dotted pattern. Fades into chart noise at default zoom — best for tertiary references.
The mistake that silently breaks dashed lines
The single most common error: trying to use hline.style_dashed with the wrong drawing function. hline() works. plot() does not — plot() uses its own plot.style_* namespace, and there is no built-in dashed style for plot() in Pine v5 or v6.
// X plot.style_dashed does not exist
plot(close, "Price", color=color.aqua, style=plot.style_dashed)
// X compiles but ignores the style — wrong namespace
plot(close, "Price", color=color.aqua, style=hline.style_dashed)
If you need a dashed series (not a fixed level), the workaround in v5 is to draw a line.new() object on each bar with extend=extend.right and style=line.style_dashed. That gives you a dashed line that follows a moving value. It's more code than a one-liner, but it's the only way to get a real dashed series in Pine.
//@version=5
indicator("dashed VWAP", overlay=true)
vwapValue = ta.vwap
var line vwapLine = na
if barstate.islast
line.delete(vwapLine)
vwapLine := line.new(bar_index - 50, vwapValue, bar_index, vwapValue,
color=color.yellow, style=line.style_dashed, width=1)
Real-world: dashed levels in a trading indicator
This is how the Scalloper indicator draws zone-of-interest levels — solid for the active SR zone, dashed for the secondary level, dotted for the kill-condition trigger. The visual hierarchy reads in one glance: solid = act, dashed = watch, dotted = bail. hline.style_dashed is doing real work in that hierarchy, not decoration.
If you're writing your own NQ futures indicator and want a reference for how production Pine code structures multi-level visual systems, the Context Engine source uses the same pattern: ORH (solid), IBH (dashed), prior day high (dotted). The line style itself is a piece of information the trader reads.
Quick reference
hline() with hline.style_* — the namespaces don't cross over to plot() or line().
input.float() as the first argument — series like close or ta.sma(close, 20) won't compile.
line.new() with style=line.style_dashed instead.
FAQ
Can I use hline.style_dashed with plot()?
No. plot() uses the plot.style_* namespace, and there is no plot.style_dashed in Pine v5 or v6. To draw a dashed line that follows a series, use line.new() with style=line.style_dashed.
What's the difference between hline.style_dashed and line.style_dashed?
hline.style_dashed is for the hline() function, which draws a fixed-price horizontal line across the entire visible chart. line.style_dashed is for the line.new() drawing object, which lets you draw a dashed segment between two specific bar/price points and animate it bar-by-bar.
Why is my dashed line showing up solid?
Most common cause: zoom level. TradingView renders dashed lines based on pixel density. At extreme zoom-out, the dashes can blend into a near-solid line. Zoom in and they reappear. The second cause: passing linestyle=hline.style_dashed to a function that ignores it (like plot()).
Does hline.style_dashed work in Pine Script v6?
Yes. The hline. namespace is unchanged across Pine v5 and v6. Both hline.style_solid, hline.style_dashed, and hline.style_dotted compile identically in either version.
Related guides
- Best TradingView Indicators for NQ Day Trading
- Scalloper v4.1 — NQ Zone Entry Indicator (uses dashed levels in production)
- Combo ORB Context Engine (multi-style HUD overlay)