fill() - Pine Script Function
fill()
Section titled “fill()”Overview
Section titled “Overview”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.
Syntax
Section titled “Syntax”fill(hline1, hline2, color, title, editable, fillgaps, display) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
hline1/plot1 | plot/hline | First plotted series or hline. Required. |
hline2/plot2 | plot/hline | Second plotted series or hline. Required. |
color | series color | Fill color. Use color.new() for transparency. |
title | const string | Optional name shown in Style settings. |
editable | const bool | Let users adjust color. Defaults to true. |
fillgaps | const bool | Whether to fill gaps between series. Defaults to true. |
display | const string | Display mode (see display.*). |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@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)