fill

Shades the band between two plots, or between two horizontal lines. It has two forms and no mixed one, so you cannot fill between a plot and a level, and like the other output calls it must sit at the top level. The forms differ in argument order, and that is the thing that bites: for two levels the third argument is the colour, for two plots it is the title. Name the arguments and the difference stops mattering. When you fill between two plots, the fill keeps an offset only if both plots carry the same one.

fill(series hline h1, series hline h2, series color color, const string title, const bool fillgaps) → void
fill(series plot p1, series plot p2, const string title, series color color, const bool fillgaps) → void
ParameterTypeRequiredDescription
h1series hlineyesThe first horizontal line. Required in the level form.
h2series hlineyesThe second horizontal line. Required in the level form.
colorseries colornoThe fill colour. Series-form. Third argument in the level form, fourth in the plot form.
titleconst stringnoThe fill’s name. Const-form. Fourth argument in the level form, third in the plot form.
fillgapsconst boolnoWhether gaps are filled. Const-form, so it is fixed for the run of the script. Last argument in both forms.
p1series plotyesThe first plot. Required in the plot form.
p2series plotyesThe second plot. Required in the plot form.

Returns void — void.

indicator("Range band")
top = plot(high, title = "High")
bottom = plot(low, title = "Low")
fill(p1 = top, p2 = bottom, title = "Range", color = color.blue)

See also fills and levels

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade