Duplicates a line, with its points, extend, color, style and width, as a new independent line.
The copy is a separate object: moving or recoloring it leaves the original alone. Use it to repeat a line at another level, such as the opposite side of a channel.
The copy goes to the end of line.all and counts toward max_lines_count like any new line, so a full chart loses its oldest line to make room.
Syntax
line.copy(id: series line) -> series line
line.copy() -> series lineArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | series line | required | The line to duplicate. Its points, xloc, extend, color, style and width carry over to the copy. |
Returns
series line: A new line with the properties of the original.
Remarks
- On Sidechair: copying na returns na, and the xloc setting travels with the copy.
Example
//@version=6
indicator("line.copy: parallel line", overlay = true)
if barstate.islast
base = line.new(bar_index - 30, low[30], bar_index, low, extend = extend.right)
top = line.copy(base)
line.set_y1(top, high[30])
line.set_y2(top, high)See also
Runs on Sidechair