box.copy() - Pine Script Function
box.copy()
Section titled “box.copy()”Overview
Section titled “Overview”Clones the box object.
Syntax
Section titled “Syntax”box.copy(id) → series boxParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | series box | Box object. |
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator('Last 50 bars price ranges', overlay = true)LOOKBACK = 50highest = ta.highest(LOOKBACK)lowest = ta.lowest(LOOKBACK)if barstate.islastconfirmedhistoryvar 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))