The type of a shape drawn through a list of chart points, as straight segments or smooth curves.
A polyline variable refers to one drawn path through an array of chart.point values. It can be open or closed, straight or curved, and can carry a fill color for the enclosed area.
Where line.new() joins exactly two points, one polyline replaces a whole chain of lines, which keeps the drawing count low when tracing a long swing path, a zigzag or an irregular shape.
Remarks
- A single polyline holds up to 10,000 points.
Example
//@version=6
indicator("polyline type: zigzag", overlay = true)
var pts = array.new<chart.point>()
ph = ta.pivothigh(high, 5, 5)
pl = ta.pivotlow(low, 5, 5)
if not na(ph)
array.push(pts, chart.point.from_index(bar_index - 5, ph))
if not na(pl)
array.push(pts, chart.point.from_index(bar_index - 5, pl))
if barstate.islast and array.size(pts) > 1
polyline.new(pts, line_color = color.orange)See also
Runs on Sidechair