Skip to content
Algo Trade Analytics Docs

line.copy() - Pine Script Function

Clones the line object.

line.copy(id) → series line
NameTypeDescription
idseries lineLine object.

New line ID object which may be passed to line.setXXX and line.getXXX functions.

//@version=6
indicator('Last 100 bars price range', overlay = true)
LOOKBACK = 100highest = ta.highest(LOOKBACK)
lowest = ta.lowest(LOOKBACK)
if barstate.islastconfirmedhistory
var 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)