Sidechair

label.copy()

Browse the reference

Makes a second label with the position, text, colors, style, size and tooltip of an existing one.

Try it in the editor

The copy is independent: editing it does not touch the original. Use the first label as a template, then move the copy with label.set_xy() or give it other text.

A copy counts against the same label limit as any other label and is the newest in the list, so when the limit is hit the oldest label goes first, not the copy.

Syntax

Pine Script
label.copy(id: series label) -> series label
label.copy() -> series label

Arguments

NameTypeDefaultDescription
idseries labelrequiredThe label to duplicate. Its position, text, fill, text color, style, size and tooltip are carried over; na gives na.

Returns

series label: A new label with the properties of the original.

Remarks

  • On Sidechair: copying na returns na, and the method form tag.copy() is the same call as label.copy(tag).

Example

Pine ScriptStack percent offsets from one templateOpen in editor
//@version=6
indicator("label.copy: offset ladder", overlay = true)
if barstate.islast
    base = label.new(bar_index + 3, close, "close", style = label.style_label_left, color = color.gray, size = size.small)
    for i = 1 to 3
        step = label.copy(base)
        label.set_y(step, close * (1 + 0.002 * i))
        label.set_text(step, "+" + str.tostring(0.2 * i) + "%")

See also

Runs on Sidechair