Skip to main content
hline draws a horizontal line at a price that is fixed for the whole run. fill shades the space between two plots or two levels. Both stand at the top level of the script (see Plotting).

Levels

hline(price, title, color, linewidth, style, display, format): price is required and is an input value, so a number, an input.* result or a constant, never a series. color is input too, so a level cannot change color by bar. style is hlineStyle.solid, dashed or dotted. hline has no force_overlay.
The compiler says: Cannot call hline with argument price=close. An argument of series float type was used but a input float is expected. A line that follows the data is a plot, or a line drawing (see Plots or drawings). hline returns an hline value that fill accepts. For a level that starts at a bar and runs on, draw line.new(..., extend=extend.right), and shade between two such lines with linefill.new (see Lines, labels, boxes and polylines).

Fill between two plots

Keep both plot results in variables and pass them to fill. The arguments are fill(p1, p2, title, color, fillgaps, display).
The color may be a series, so the band changes color by bar. A fill keeps a plot offset only when both plots have the same one. It follows its plots into their pane and has no force_overlay.

Fill between two levels

The two-level form puts the color third and the title fourth: fill(h1, h2, color, title, fillgaps, display). Name the arguments and the order stops mattering.

Gradient fills

Both forms have a gradient version: fill(p1, p2, top_value, bottom_value, top_color, bottom_color, title, display, fillgaps, editable) for plots (the first two names are plot1 and plot2 if you name them) and the same with h1, h2 for levels. The four of top_value, bottom_value, top_color and bottom_color are required; the values are numbers, the colors are series. editable (default true) is stored with the fill. The terminal does the shading.

What fill does not accept

fill joins plot or hline results, never series and never one of each:
The compiler says: Cannot call fill with argument h1=p. An argument of series plot type was used but a series hline is expected. For a band between a plot and a price, plot the price with plot(50). display on fill takes only display.none and display.all. The editor accepts display.pane; adding the script to the chart refuses it with: fill() display argument only supports display.none and display.all.