label.copy() - Pine Script Function
label.copy()
Section titled “label.copy()”Overview
Section titled “Overview”Clones the label object.
Syntax
Section titled “Syntax”label.copy(id) → series labelParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | series label | Label object. |
Returns
Section titled “Returns”New label ID object which may be passed to label.setXXX and label.getXXX functions.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator('Last 100 bars highest/lowest', overlay = true)LOOKBACK = 100highest = ta.highest(LOOKBACK)highestBars = ta.highestbars(LOOKBACK)lowest = ta.lowest(LOOKBACK)lowestBars = ta.lowestbars(LOOKBACK)if barstate.islastconfirmedhistoryvar labelHigh = label.new(bar_index + highestBars, highest, str.tostring(highest), color = color.green)var labelLow = label.copy(labelHigh)label.set_xy(labelLow, bar_index + lowestBars, lowest)label.set_text(labelLow, str.tostring(lowest))label.set_color(labelLow, color.red)label.set_style(labelLow, label.style_label_up)