Pine programmers love having different options when displaying indicator calculations on charts, and with good reason. How we present information is just as important as the information itself, because well-designed visuals make indicators easier to use.
Our newest addition to the Pine toolbox allows you to fill the space between two line drawings using a new “linefill” drawing type and its accompanying functions.
The basics are simple: to fill the space between two line drawings, call the linefill.new() function with their ID and a color. Any two-line pair can only have one linefill between them, so successive calls to linefill.new() on the same pair of lines will replace the previous fill with a new one.
The behavior of linefills is dependent on the lines they are attached to. If both lines extend in the same direction, the linefill will follow their extensions, as can be seen in the following script’s display.
In the example below, our indicator draws two lines connecting the last two high and low pivot points of the chart. We extend the lines to the right to project the short-term movement of the chart, and fill the space between them to enhance the visibility of the channel the lines create:
//@version=5 indicator("Channel", overlay = true) LEN_LEFT = 15 LEN_RIGHT = 5 pH = ta.pivothigh(LEN_LEFT, LEN_RIGHT) pL = ta.pivotlow(LEN_LEFT, LEN_RIGHT) // Bar indices of pivot points pH_x1 = ta.valuewhen(pH, bar_index, 1) - LEN_RIGHT pH_x2 = ta.valuewhen(pH, bar_index, 0) - LEN_RIGHT pL_x1 = ta.valuewhen(pL, bar_index, 1) - LEN_RIGHT pL_x2 = ta.valuewhen(pL, bar_index, 0) - LEN_RIGHT // Price values of pivot points pH_y1 = ta.valuewhen(pH, pH, 1) pH_y2 = ta.valuewhen(pH, pH, 0) pL_y1 = ta.valuewhen(pL, pL, 1) pL_y2 = ta.valuewhen(pL, pL, 0) if barstate.islastconfirmedhistory // Lines lH = line.new(pH_x1, pH_y1, pH_x2, pH_y2, extend = extend.right) lL = line.new(pL_x1, pL_y1, pL_x2, pL_y2, extend = extend.right) // Fill fillColor = switch pH_y2 > pH_y1 and pL_y2 > pL_y1 => color.green pH_y2 < pH_y1 and pL_y2 < pL_y1 => color.red => color.silver linefill.new(lH, lL, color.new(fillColor, 90))
You can learn more about the linefill functionality in our Reference Manual: just type “linefill” in the search field to bring up all related functions. Or, if you prefer to learn from the greats, the following examples show how some of our PineCoders have used linefills:
To stay informed of new Pine features, keep an eye on our User Manual’s Release notes. Our PineCoders also broadcast updates from the Squawk Box Telegram channel, Twitter, and from the Pine Script public chat on TradingView.
We hope you find these highly-requested features useful. Please keep giving us your feedback and suggestions for improvement. We build TradingView for you, and we’re always keen to hear from you.