line.new() - Pine Script Function
line.new()
Section titled “line.new()”Overview
Section titled “Overview”Creates new line object.
Syntax
Section titled “Syntax”line.new(first_point, second_point, xloc, extend, color, style, width, force_overlay) → series lineParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| first_point | chart.point | A chart.point object that specifies the line’s starting coordinate. |
Returns
Section titled “Returns”Line ID object which may be passed to line.setXXX and line.getXXX functions.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("line.new")var line1 = line.new(0, low, bar_index, high, extend=extend.right)var line2 = line.new(time, open, time + 60 * 60 * 24, close, xloc=xloc.bar_time, style=line.style_dashed)line.set_x2(line1, 0)line.set_xloc(line1, time, time + 60 * 60 * 24, xloc.bar_time)line.set_color(line2, color.green)line.set_width(line2, 5)