Sidechair

chart.point.from_index()

Browse the reference

Creates a chart point from a bar index and a price, with the time left empty.

Try it in the editor

The point works with drawings placed by bar index, which is the default xloc. Its time field is na, so it cannot place a drawing by timestamp.

It suits swings, where you know the bar offset and the level: chart.point.from_index(bar_index - 5, ph).

Syntax

Pine Script
chart.point.from_index(index: series int, price: series int/float) -> chart.point

Arguments

NameTypeDefaultDescription
indexseries intrequiredBar index of the anchor, such as bar_index - 5 for a swing five bars back. The point's time is left na.
priceseries int/floatrequiredPrice level of the anchor, such as a pivot value. It is the y value drawings use for this point.

Returns

chart.point: A new chart.point with a bar index and a price.

Example

Pine ScriptPivot highs as pointsOpen in editor
//@version=6
indicator("chart.point.from_index: pivot", overlay = true)
ph = ta.pivothigh(high, 5, 5)
if not na(ph)
    p = chart.point.from_index(bar_index - 5, ph)
    label.new(p, "H", style = label.style_label_down)

See also

Runs on Sidechair