Lipi Reference Lipi

Functions

fill()

Fills background between two plots or hlines with a given color.

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


          indicator("Fill Example", overlay=true)
// Create two moving averages
ma1 = ta.sma(close, 20)
ma2 = ta.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))