Skip to main content
plot returns a plot value. Assign each plot to a variable at the top level, then hand both variables to fill. Name the arguments: the form for two horizontal lines takes the color and the title in the opposite order, and names remove the difference.

Plain fill

fill(p1, p2, title, color) shades the band with one color. The color is a series value, so a condition inside it changes the shade bar by bar. color.new(color, alpha) takes an opacity from 0 to 1, so use a low value for a light shade.

Gradient fill

The gradient form adds four values: fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color, title). Each bar the shade runs from top_color at top_value to bottom_color at bottom_value, changing gradually between. All four are required; the values are numbers and may be series, so pass the two prices that bound the band to make the gradient span it on every bar.

Between two levels

For two hline values, use fill(h1, h2, color, title) or, with a gradient, fill(h1, h2, top_value, bottom_value, top_color, bottom_color). There is no form that takes a plot and a level.

The mistake to avoid

Mixing a plot and a level. The compiler says: Cannot call fill with argument h1=p. An argument of series plot type was used but a series hline is expected.
When you fill between two plots, the fill keeps an offset only if both plots carry the same one. fill and the plots it joins must be called at the top level, and the fill follows its plots into their pane (it has no force_overlay). To shade between two lines drawn with line.new, use linefill.new (see Lines, labels, boxes and polylines). See Fills and levels.