Sidechair

line.set_second_point()

Browse the reference

Replaces the end of a line with a chart.point, bar and price together.

Try it in the editor

The point supplies the bar and the price at once, standing in for a line.set_xy2() call. It suits code that keeps swing points as chart.point values and draws between them.

Create the point with chart.point.now() for the current bar or with chart.point.from_time() for a timestamp.

Syntax

Pine Script
line.set_second_point(id: series line, point: chart.point) -> void
line.set_second_point(point: chart.point) -> void

Arguments

NameTypeDefaultDescription
idseries linerequiredThe line whose second end is replaced by the point.
pointchart.pointrequiredA chart.point carrying the new index or time and the price for the second end.

Returns

Nothing.

Example

Pine ScriptTrack the current barOpen in editor
//@version=6
indicator("line.set_second_point: track now", overlay = true)
var line ln = line.new(bar_index, close, bar_index + 1, close)
line.set_second_point(ln, chart.point.now(close))

See also

Runs on Sidechair