Skip to content

fill() - Pine Script Function

fill() shades the space between two plot-based series (plots or hline objects). It is commonly used for channel visualization, gradients, and spread highlighting. The function accepts either plot IDs or hline references.

fill(hline1, hline2, color, title, editable, fillgaps, display) → void
NameTypeDescription
hline1/plot1plot/hlineFirst plotted series or hline. Required.
hline2/plot2plot/hlineSecond plotted series or hline. Required.
colorseries colorFill color. Use color.new() for transparency.
titleconst stringOptional name shown in Style settings.
editableconst boolLet users adjust color. Defaults to true.
fillgapsconst boolWhether to fill gaps between series. Defaults to true.
displayconst stringDisplay mode (see display.*).
//@version=6indicator("Gradient Fill between hlines", overlay = false)topVal = input.int(100)botVal = input.int(0)topCol = input.color(color.red)botCol = input.color(color.blue)topLine = hline(100, color = topCol, linestyle = hline.style_solid)botLine = hline(0,   color = botCol, linestyle = hline.style_solid)fill(topLine, botLine, topVal, botVal, topCol, botCol)