hline

hline draws a horizontal line at a fixed price level on the chart. Unlike line.new(), it renders across the entire chart history and future bars. The module itself is callable — hline(...) creates a line, while hline.style_* constants control its appearance.

Quick Example

from pynecore.lib import script, hline, color

@script.indicator(title="Support/Resistance Levels", overlay=True)
def main():
    hline(100.0, title="Resistance", color=color.red, linestyle=hline.style_dashed, linewidth=2)
    hline(50.0, title="Support", color=color.green, linestyle=hline.style_solid)

Functions

hline()

Renders a horizontal line at a fixed price level that spans the entire chart.

ParameterTypeDefaultDescription
pricefloatrequiredPrice level at which the line is drawn
titlestr""Label for the line (shown in Format dialog)
colorcolor.Colorcolor.blueLine color — must be a constant, not a dynamic expression
linestyleHLineEnumhline.style_solidLine style — one of hline.style_solid, hline.style_dotted, hline.style_dashed
linewidthint1Line thickness in pixels
editableboolTrueWhether the style is editable in the Format dialog
displaydisplay.Displaydisplay.allWhere to display the line — display.all or display.none

Returns: HLine — an hline object that can be used with fill()

mid: HLine = hline(200.0, title="Midpoint", color=color.gray, linestyle=hline.style_dotted)

Constants

ConstantDescription
hline.style_solidSolid line style (default)
hline.style_dottedDotted line style
hline.style_dashedDashed line style

Compatibility

All three style constants and the hline() function are fully supported. Note that the color parameter must be a constant value — dynamic (per-bar) color expressions are not supported.