Shades the area between two plots or two horizontal lines with a solid or gradient color.
fill takes two handles of the same kind, either two plot results or two hline results, and shades the space between them. The color can change per bar, so a fill can flip between two colors as the plots cross.
The gradient form takes top_value, bottom_value, top_color and bottom_color and blends from one color to the other across that value range. Handles are read from variables, so assign each plot call to a name first.
Syntax
fill(plot1: plot, plot2: plot, top_value: series int/float (optional), bottom_value: series int/float (optional), top_color: series color (optional), bottom_color: series color (optional), title: const string (optional), display: input plot_simple_display (optional), fillgaps: const bool (optional), editable: input bool (optional)) -> void
fill(hline1: hline, hline2: hline, color: series color (optional), title: const string (optional), editable: input bool (optional), fillgaps: const bool (optional), display: input plot_simple_display (optional)) -> void
fill(plot1: plot, plot2: plot, color: series color (optional), title: const string (optional), editable: input bool (optional), show_last: input int (optional), fillgaps: const bool (optional), display: input plot_simple_display (optional)) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| plot1 | plot | required | First plot handle, from plot(). |
| plot2 | plot | required | Second plot handle, from plot(). |
| top_value | series int/ | na | Value that gets top_color in a gradient fill. |
| bottom_value | series int/ | na | Value that gets bottom_color in a gradient fill. |
| top_color | series color | na | Color at the top of the gradient. |
| bottom_color | series color | na | Color at the bottom of the gradient. |
| title | const string | "" | Name shown in the Settings dialog. |
| display | input plot_simple_display | display. | Where the fill is shown. display.none hides it. |
| fillgaps | const bool | false | Accepted for compatibility and ignored. |
| editable | input bool | true | Accepted for compatibility and ignored. |
| hline1 | hline | required | First hline handle, from hline(). |
| hline2 | hline | required | Second hline handle, from hline(). |
| color | series color | #2962FF1A | Fill color, evaluated per bar. Use color.new for transparency. |
| show_last | input int | na | Accepted for compatibility and ignored. |
Returns
Nothing.
Remarks
- On Sidechair: the fill color defaults to a faint blue (#2962FF at 90% transparency) when none is given.
- The two plots must be plot handles, not values. fill(close, open) does not compile; assign p1 = plot(close) first.
- A fill between plots shades only the bars where both plots have values.
Example
//@version=6
indicator("Average cloud", overlay = true)
fast = ta.ema(close, 12)
slow = ta.ema(close, 26)
p1 = plot(fast, "Fast", color = color.green)
p2 = plot(slow, "Slow", color = color.red)
fill(p1, p2, color = fast >= slow ? color.new(color.green, 85) : color.new(color.red, 85), title = "Cloud")See also
Runs on Sidechair