Functions
polyline.new()
Creates a polyline from an array of chart.point objects. The drawing is bar/price anchored via those points.
Syntax
polyline.new(series array<chartPoint> points, series bool curved, series bool closed, series string xloc, series color line_color, series color fill_color, series string line_style, series int line_width, const bool force_overlay) → series polyline
Arguments
points required series array<chartPoint> Array of chart.point vertices, in drawing order. curved series bool If true, connect points with a curve. Default is false. closed series bool If true, connect the last point back to the first. Default is false. xloc series string How x-coordinates are interpreted: xloc.bar_index or xloc.bar_time. Default is xloc.bar_index. line_color series color Stroke color. Optional. fill_color series color Interior fill color when the polyline is closed. Optional. line_style series string Stroke style (line.style_*). Optional. line_width series int Stroke width in pixels. Optional. force_overlay const bool If true, draw on the main pane even when the script is not overlay. Default is false. Return Type
series polyline Example
//@lipi=2
indicator("polyline.new Example", overlay=true)
if barstate.islast {
pts = array.new<chartPoint>(0)
array.push(pts, chartPoint.from_index(bar_index[20], low[20]))
array.push(pts, chartPoint.from_index(bar_index[10], high[10]))
array.push(pts, chartPoint.from_index(bar_index, close))
polyline.new(pts, curved=false, closed=false, line_color=color.orange, line_width=2)
}