Sidechair

linefill.set_color()

Browse the reference

Recolors the shaded band between a fill's two lines without touching the lines.

Try it in the editor

Only the fill changes; the lines keep their own colors. Use color.new(c, transparency) so the candles stay visible beneath the band.

Recolor it per bar to show state, such as green when the last close is above the band's midpoint and red when below.

Syntax

Pine Script
linefill.set_color(id: series linefill, color: series color) -> void
linefill.set_color(color: series color) -> void

Arguments

NameTypeDefaultDescription
idseries linefillrequiredThe linefill to recolor; the colors of its two bounding lines do not change.
colorseries colorrequiredNew fill color. The transparency inside color.new() decides how much of the chart shows through the band.

Returns

Nothing.

Example

Pine ScriptBand follows directionOpen in editor
//@version=6
indicator("linefill.set_color: direction", overlay = true)
var linefill f = na
if barstate.islast
    f := linefill.new(line.new(bar_index - 20, high, bar_index, high), line.new(bar_index - 20, low, bar_index, low), color.gray)
    linefill.set_color(f, close > open ? color.new(color.green, 85) : color.new(color.red, 85))

See also

Runs on Sidechair