Skip to content

linefill ​

How do you shade the space between two lines? Call linefill.new with both lines and a colour. The fill follows the lines wherever they move, and goes when either line is deleted.

pine
//@version=6
indicator("50-bar channel", overlay = true)
hi = ta.highest(high, 50)
lo = ta.lowest(low, 50)
var line top = line.new(na, na, na, na, color = color.green)
var line bot = line.new(na, na, na, na, color = color.green)
if barstate.isfirst
    // Made once: moving the lines moves the fill.
    linefill.new(top, bot, color.new(color.green, 85))
if barstate.islast
    line.set_xy1(top, bar_index - 49, hi)
    line.set_xy2(top, bar_index, hi)
    line.set_xy1(bot, bar_index - 49, lo)
    line.set_xy2(bot, bar_index, lo)

A linefill made on the same two lines as a live one, in either order, replaces it. One whose line was deleted, or that was replaced or deleted itself, leaves the chart and linefill.all, and its getters read na. A line the line count takes leaves its linefill in place.

linefill.new ​

pine
linefill.new(line1, line2, color) → series linefill

Fills the space between two lines, and returns the fill's handle.

ParameterDescription
line1
series line
The first line.
line2
series line
The second line.
color
series color
The fill's colour.

linefill.get_line1 ​

pine
linefill.get_line1(id) → series line

Also a method: id.get_line1().

The fill's first line.

ParameterDescription
id
series linefill
The linefill.

linefill.get_line2 ​

pine
linefill.get_line2(id) → series line

Also a method: id.get_line2().

The fill's second line.

ParameterDescription
id
series linefill
The linefill.

linefill.set_color ​

pine
linefill.set_color(id, color) → void

Also a method: id.set_color(color).

Sets the fill's colour.

ParameterDescription
id
series linefill
The linefill.
color
series color
The colour.

linefill.delete ​

pine
linefill.delete(id) → void

Also a method: id.delete().

Takes the fill off the chart and out of linefill.all. The lines stay.

ParameterDescription
id
series linefill
The linefill.

linefill.all ​

pine
array<linefill> linefill.all

An array of every linefill the script has on the chart, oldest first.

See also ​

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.