Skip to content
Algo Trade Analytics Docs

box.copy() - Pine Script Function

Clones the box object.

box.copy(id) → series box
NameTypeDescription
idseries boxBox object.
//@version=6
indicator('Last 50 bars price ranges', overlay = true)
LOOKBACK = 50highest = ta.highest(LOOKBACK)
lowest = ta.lowest(LOOKBACK)
if barstate.islastconfirmedhistory
var BoxLast = box.new(bar_index[LOOKBACK], highest, bar_index, lowest, bgcolor = color.new(color.green, 80))
var BoxPrev = box.copy(BoxLast)
box.set_lefttop(BoxPrev, bar_index[LOOKBACK * 2], highest[50])
box.set_rightbottom(BoxPrev, bar_index[LOOKBACK], lowest[50])
box.set_
bgcolor(BoxPrev, color.new(color.red, 80))