Draws a horizontal line across the whole pane at a fixed price, and returns a handle that fill can use.
hline draws one horizontal line at price. The price is read on the first bar and cannot change, so use plot with a constant series if the level must move.
Style, width and color are fixed from the first bar as well. The returned handle can be given to fill to shade the band between two lines.
Syntax
hline(price: input int/float, title: const string (optional), color: input color (optional), linestyle: input hline_style (optional), linewidth: input int (optional), editable: input bool (optional), display: input plot_simple_display (optional)) -> hlineArguments
| Name | Type | Default | Description |
|---|---|---|---|
| price | input int/ | required | The level to draw. A fixed number, read once. |
| title | const string | "Level" | Name shown in the Settings dialog. |
| color | input color | #787B86 | Color of the horizontal line. It takes an input color or a fixed color, not a series. |
| linestyle | input hline_style | hline. | Line style: hline.style_solid, hline.style_dotted or hline.style_dashed. |
| linewidth | input int | 1 | Line thickness in pixels. A whole number of 1 or more. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| display | input plot_simple_display | display. | Where the line is shown. display.none hides it. |
Returns
hline: an hline handle, accepted by fill.
Remarks
- On Sidechair: line widths above 4 are drawn as 4.
- Two hline handles passed to fill shade the band between the levels, which is how oscillator zones are drawn.
Example
//@version=6
indicator("RSI zones")
upper = hline(70, "Upper", color.red, hline.style_dotted)
lower = hline(30, "Lower", color.green, hline.style_dotted)
fill(upper, lower, color.new(color.purple, 92), "Neutral zone")
plot(ta.rsi(close, 14), "RSI", color = color.purple)See also
Runs on Sidechair