Functions
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.
Syntax · 1 of 2
fill(series hline h1, series hline h2, series color color, const string title, const bool fillgaps) → void
Arguments
h1 required series hline The first hline object. Required argument. h2 required series hline The second hline object. Required argument. color series color Color of the background fill. You can use predefined constants such as 'blue' or '#00ff7f', as well as complex expressions like 'close >= open ? color.yellow : color.blue'. This is a required argument. title const string Title of the created fill object. Optional argument. fillgaps const bool Controls continuing fills on gaps, i.e., when one of the plot() calls returns an na value. When true, the last fill will continue on gaps. The default is false. Return Type
void Syntax · 2 of 2
fill(series plot p1, series plot p2, const string title, series color color, const bool fillgaps) → void
Arguments
p1 required series plot The first plot object. Required argument. p2 required series plot The second plot object. Required argument. title const string Title of the created fill object. Optional argument. color series color Color of the background fill. You can use predefined constants such as 'blue' or '#00ff7f', as well as complex expressions like 'close >= open ? color.yellow : color.blue'. This is a required argument. fillgaps const bool Controls continuing fills on gaps, i.e., when one of the plot() calls returns an na value. When true, the last fill will continue on gaps. The default is false. Return Type
void Example
//@lipi=2
indicator("Fill Example", overlay=true)
// Create two moving averages
ma1 = talib.sma(close, 20)
ma2 = talib.sma(close, 50)
// Plot moving averages
plot1 = plot(ma1, color=color.blue, title="MA 20")
plot2 = plot(ma2, color=color.orange, title="MA 50")
// Fill the area between MA 20 and MA 50
fill(plot1, plot2, color=color.new(color.green, 0.1))