Sidechair

fill()

Browse the reference

Shades the area between two plots or two horizontal lines with a solid or gradient color.

Try it in the editor

fill takes two handles of the same kind, either two plot results or two hline results, and shades the space between them. The color can change per bar, so a fill can flip between two colors as the plots cross.

The gradient form takes top_value, bottom_value, top_color and bottom_color and blends from one color to the other across that value range. Handles are read from variables, so assign each plot call to a name first.

Syntax

Pine Script
fill(plot1: plot, plot2: plot, top_value: series int/float (optional), bottom_value: series int/float (optional), top_color: series color (optional), bottom_color: series color (optional), title: const string (optional), display: input plot_simple_display (optional), fillgaps: const bool (optional), editable: input bool (optional)) -> void
fill(hline1: hline, hline2: hline, color: series color (optional), title: const string (optional), editable: input bool (optional), fillgaps: const bool (optional), display: input plot_simple_display (optional)) -> void
fill(plot1: plot, plot2: plot, color: series color (optional), title: const string (optional), editable: input bool (optional), show_last: input int (optional), fillgaps: const bool (optional), display: input plot_simple_display (optional)) -> void

Arguments

NameTypeDefaultDescription
plot1plotrequiredFirst plot handle, from plot().
plot2plotrequiredSecond plot handle, from plot().
top_valueseries int/floatnaValue that gets top_color in a gradient fill.
bottom_valueseries int/floatnaValue that gets bottom_color in a gradient fill.
top_colorseries colornaColor at the top of the gradient.
bottom_colorseries colornaColor at the bottom of the gradient.
titleconst string""Name shown in the Settings dialog.
displayinput plot_simple_displaydisplay.allWhere the fill is shown. display.none hides it.
fillgapsconst boolfalseAccepted for compatibility and ignored.
editableinput booltrueAccepted for compatibility and ignored.
hline1hlinerequiredFirst hline handle, from hline().
hline2hlinerequiredSecond hline handle, from hline().
colorseries color#2962FF1AFill color, evaluated per bar. Use color.new for transparency.
show_lastinput intnaAccepted for compatibility and ignored.

Returns

Nothing.

Remarks

  • On Sidechair: the fill color defaults to a faint blue (#2962FF at 90% transparency) when none is given.
  • The two plots must be plot handles, not values. fill(close, open) does not compile; assign p1 = plot(close) first.
  • A fill between plots shades only the bars where both plots have values.

Example

Pine ScriptCloud between two averagesOpen in editor
//@version=6
indicator("Average cloud", overlay = true)
fast = ta.ema(close, 12)
slow = ta.ema(close, 26)
p1 = plot(fast, "Fast", color = color.green)
p2 = plot(slow, "Slow", color = color.red)
fill(p1, p2, color = fast >= slow ? color.new(color.green, 85) : color.new(color.red, 85), title = "Cloud")

See also

Runs on Sidechair