line.copy() - Pine Script Function
line.copy()
Section titled “line.copy()”Overview
Section titled “Overview”Clones the line object.
Syntax
Section titled “Syntax”line.copy(id) → series lineParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | series line | Line object. |
Returns
Section titled “Returns”New line ID object which may be passed to line.setXXX and line.getXXX functions.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator('Last 100 bars price range', overlay = true)LOOKBACK = 100highest = ta.highest(LOOKBACK)lowest = ta.lowest(LOOKBACK)if barstate.islastconfirmedhistoryvar lineTop = line.new(bar_index[LOOKBACK], highest, bar_index, highest, color = color.green)var lineBottom = line.copy(lineTop)line.set_y1(lineBottom, lowest)line.set_y2(lineBottom, lowest)line.set_color(lineBottom, color.red)