Skip to content
Algo Trade Analytics Docs
Pine library page — review pending. This page is preserved for compatibility but is not part of the reviewed search index. Check the official Pine Script v6 reference before relying on its explanation, signature, or example.

hline() - Pine Script Function

hline() draws a horizontal line at a constant price level. The function returns a handle you can reuse to change color, fill between lines, or delete it later.

hline(price, title, color, linestyle, linewidth, editable, display) → hline
NameTypeDescription
priceconst floatPrice level for the line. Required.
titleconst stringLabel shown in the Style settings.
colorconst colorLine color (defaults to chart theme).
linestyleconst line.styleLine style (solid, dotted, dashed).
linewidthconst intLine thickness.
editableconst boolAllow users to adjust style in the settings panel. Defaults to true.
displayconst stringDisplay mode (see display.*).

An hline object that can be passed to functions like fill() or deleted later.

//@version=6
indicator("hline example", overlay=true)
mid = plot(ta.sma(close, 50), "Mid", color=color.orange)
upperLevel = hline(ta.sma(close, 50) + ta.atr(14), "Upper", color=color.green)
lowerLevel = hline(ta.sma(close, 50) - ta.atr(14), "Lower", color=color.red)
fill(upperLevel, lowerLevel, color.new(color.teal, 90))
plot(close, "Close", color=color.blue)