Casts a value to the line type, mainly so that na can be given a line type.
line(na) is a line-typed na, the starting value a variable needs before it holds a real line. An existing line passes through unchanged.
The shorter declaration line ln = na does the same in most scripts.
Syntax
line(x: series line) -> series lineArguments
| Name | Type | Default | Description |
|---|---|---|---|
| x | series line | required | The value to convert to a line. Passing na gives a line-typed na; an existing line comes back unchanged. |
Returns
series line: The argument, typed as a line.
Example
//@version=6
indicator("line cast: typed na", overlay = true)
var l = line(na)
if bar_index % 40 == 0
l := line.new(bar_index, high, bar_index + 10, high)
plot(na(l) ? 0 : 1, "Line exists")See also
Runs on Sidechair