Evaluates the straight line through two points at any bar and returns its price there.
The line is treated as running forever in both directions, so the answer is defined for any x, even one beyond the drawn segment or before it. At x1 it equals the first price and at x2 the second, with a straight-line step between and beyond.
A vertical line, whose two x values are equal, has no single price at x and returns na. A na line returns na as well.
Syntax
line.get_price(id: series line, x: series int) -> series float
line.get_price(x: series int) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to read the price from; it is treated as infinite, so x may lie outside its segment. |
| x | series int | required | Bar index, or a millisecond timestamp for a line placed with xloc.bar_time, at which to evaluate the line. |
Returns
series float: The price of the line at x.
Remarks
- On Sidechair: the extend setting does not change the answer, so a line with
extend.nonestill reports prices outside its segment.
Example
//@version=6
indicator("line.get_price: trend level", overlay = true)
var line trend = line.new(0, 0, 1, 1)
if bar_index == 100
trend := line.new(bar_index - 50, close[50], bar_index, close, extend = extend.right)
plot(bar_index > 100 ? line.get_price(trend, bar_index) : na, "Trendline price")See also
Runs on Sidechair