> ## Documentation Index
> Fetch the complete documentation index at: https://gocharting.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# label functions

> Reference for the 22 functions of the label namespace: label.all, label.copy, label.delete, label.get_text and 18 more, each with its definition and an example.

> [!NOTE]
>
> Language version: 2 · Reference version: 2.7 · Date: 2026-10-25 · Compiler build: df7b3b14 · Namespace: label · Entries: 23

## `label` (library)

**Definition**

Functions for creating and mutating text label drawings on the chart.

**Notes**

* A `label.<name>(l, ...)` function can also be called on the label as `l.<name>(...)`, for example `l.set_text("u")`.

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label Library Example", overlay=true)
static label lastLabel = label(na)
if barstate.islast {
    if not na(lastLabel) {
        label.delete(lastLabel)
    }
    lastLabel := label.new(bar_index, high, text="Close", style=label.style_label_down, color=color.blue, textcolor=color.white)
    label.set_text(lastLabel, "Close: " + str.tostring(math.round(close, 2)))
}
```

## `label.all` (function)

**Definition**

Returns the array of all existing label objects (same as label.all).

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.all() → series array<label>
```

**Returns**

`series array<label>`

An array of label IDs, oldest to newest.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.all Example", overlay=true)
plot(array.length(label.all), title="Count")
```

## `label.copy` (function)

**Definition**

Creates a copy of a label.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.copy(series label id) → series label
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |

**Returns**

`series label`

The new label ID.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.copy Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    c = label.copy(lb)
}
```

## `label.delete` (function)

**Definition**

Deletes a label.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.delete(series label id) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.delete Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.delete(lb)
}
```

## `label.get_text` (function)

**Definition**

Returns a label's text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.get_text(series label id) → series string
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |

**Returns**

`series string`

The label text.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.get_text Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_text(lb, label.get_text(lb) + " " + str.tostring(close))
}
```

## `label.get_x` (function)

**Definition**

Returns a label's x-coordinate.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.get_x(series label id) → series int
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |

**Returns**

`series int`

X-coordinate.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.get_x Example", overlay=true)
static label lb = label(na)
if barstate.islast {
    lb := label.new(bar_index, high, text="Hi", color=color.green)
}
plot(na(lb) ? na : label.get_x(lb))
```

## `label.get_y` (function)

**Definition**

Returns a label's y-coordinate (price).

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.get_y(series label id) → series float
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |

**Returns**

`series float`

Y-coordinate.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.get_y Example", overlay=true)
static label lb = label(na)
if barstate.islast {
    lb := label.new(bar_index, high, text="Hi", color=color.green)
}
plot(na(lb) ? na : label.get_y(lb))
```

## `label.new` (function)

**Definition**

Creates a label at (x, y) with optional text, color, and style.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.new(series int x, series float y, series string text, series string xloc, series string yloc, series color color, series string style, series color textcolor, series size size, series string textalign, series string tooltip, input font text_font_family, const bool force_overlay, series string text_formatting) → series label
```

**Parameters**

| Name | Type | Required | Description | Values | Default |
| - | - | - | - | - | - |
| `x` | `series int` | yes | X-coordinate (bar index or time, depending on xloc). | | |
| `y` | `series float` | yes | Y-coordinate (price). | | |
| `text` | `series string` | no | Label text. Optional. | | `""` |
| `xloc` | `series string` | no | xloc.bar\_index or xloc.bar\_time. Default is bar\_index. | `xloc.bar_index`, `xloc.bar_time` | `xloc.bar_index` |
| `yloc` | `series string` | no | Vertical location relative to the bar (yloc.price, etc.). Optional. | `yloc.abovebar`, `yloc.belowbar`, `yloc.price` | `yloc.price` |
| `color` | `series color` | no | Label background color. Optional. | | `na` |
| `style` | `series string` | no | Label style (label.style\_\*). Optional. | `label.style_arrowdown`, `label.style_arrowup`, `label.style_circle`, `label.style_cross`, `label.style_diamond`, `label.style_flag`, `label.style_label_center`, `label.style_label_down`, `label.style_label_left`, `label.style_label_lower_left`, `label.style_label_lower_right`, `label.style_label_right`, `label.style_label_up`, `label.style_label_upper_left`, `label.style_label_upper_right`, `label.style_none`, `label.style_square`, `label.style_text_outline`, `label.style_triangledown`, `label.style_triangleup`, `label.style_xcross` | `label.style_label_down` |
| `textcolor` | `series color` | no | Text color. Optional. | | `na` |
| `size` | `series size` | no | Label size (`size.auto`, `size.tiny` … `size.huge`). Optional. Default is `size.normal`. | | `size.normal` |
| `textalign` | `series string` | no | Text alignment: `text.align_left`, `text.align_center` or `text.align_right`. | `text.align_left`, `text.align_center`, `text.align_right` | `text.align_center` |
| `tooltip` | `series string` | no | Tooltip text shown on hover. Optional. | | `""` |
| `text_font_family` | `input font` | no | Font family for label text (`font.family_default` or `font.family_monospace`). Optional. Default is `font.family_default`. | | `font.family_default` |
| `force_overlay` | `const bool` | no | If true, draw on the main pane even when the script is not overlay. Default is false. | | `false` |
| `text_formatting` | `series string` | no | Text formatting (none, bold, italic). Optional. | `text.format_bold`, `text.format_italic`, `text.format_none` | `text.format_none` |

**Returns**

`series label`

The ID of the created label.

**Notes**

* The `size` argument takes a `size.*` constant (`size.auto`, `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`). A string such as "small" still compiles, with a deprecation warning: write the constant. A string that is not a size name, such as "giant", stops the compiler with the error "internal validator error".

**Example**

```lipi wrap theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.new Example", overlay=true)
if barstate.islast {
    label.new(bar_index, high, text="High", color=color.green, style=label.style_label_down, textcolor=color.white)
}
```

## `label.set_color` (function)

**Definition**

Sets a label's background color.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_color(series label id, series color color) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `color` | `series color` | yes | Color value. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_color Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_color(lb, color.red)
}
```

## `label.set_point` (function)

**Definition**

Sets a label's position from a chartPoint.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_point(series label id, series chartPoint point) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `point` | `series chartPoint` | yes | A chartPoint. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_point Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_point(lb, chartPoint.from_index(bar_index, close))
}
```

## `label.set_size` (function)

**Definition**

Sets a label's size.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_size(series label id, series size size) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `size` | `series size` | yes | Label size: a `size.*` constant. A string such as "small" still compiles, with a deprecation warning. |

**Returns**

`void`

void

**Notes**

* The `size` argument takes a `size.*` constant (`size.auto`, `size.tiny`, `size.small`, `size.normal`, `size.large`, `size.huge`). A string such as "small" still compiles, with a deprecation warning: write the constant.

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_size Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_size(lb, size.small)
}
```

## `label.set_style` (function)

**Definition**

Sets a label's style (label.style\_\*).

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_style(series label id, series string style) → void
```

**Parameters**

| Name | Type | Required | Description | Values |
| - | - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. | |
| `style` | `series string` | yes | Style constant for this drawing type. | `label.style_arrowdown`, `label.style_arrowup`, `label.style_circle`, `label.style_cross`, `label.style_diamond`, `label.style_flag`, `label.style_label_center`, `label.style_label_down`, `label.style_label_left`, `label.style_label_lower_left`, `label.style_label_lower_right`, `label.style_label_right`, `label.style_label_up`, `label.style_label_upper_left`, `label.style_label_upper_right`, `label.style_none`, `label.style_square`, `label.style_text_outline`, `label.style_triangledown`, `label.style_triangleup`, `label.style_xcross` |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_style Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_style(lb, label.style_label_down)
}
```

## `label.set_text` (function)

**Definition**

Sets a label's text.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_text(series label id, series string text) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `text` | `series string` | yes | Text string. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_text Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_text(lb, str.tostring(close))
}
```

## `label.set_text_font_family` (function)

**Definition**

Sets a label's font family.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_text_font_family(series label id, input font family) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `family` | `input font` | yes | Font family (`font.family_default` or `font.family_monospace`). |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_text_font_family Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_text_font_family(lb, font.family_default)
}
```

## `label.set_text_formatting` (function)

**Definition**

Sets a label's text formatting.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_text_formatting(series label id, series string formatting) → void
```

**Parameters**

| Name | Type | Required | Description | Values |
| - | - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. | |
| `formatting` | `series string` | yes | Text formatting: `text.format_none`, `text.format_bold` or `text.format_italic`. | `text.format_bold`, `text.format_italic`, `text.format_none` |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_text_formatting Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_text_formatting(lb, "bold")
}
```

## `label.set_textalign` (function)

**Definition**

Sets a label's text alignment.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_textalign(series label id, series string textalign) → void
```

**Parameters**

| Name | Type | Required | Description | Values |
| - | - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. | |
| `textalign` | `series string` | yes | Text alignment: `text.align_left`, `text.align_center` or `text.align_right`. | `text.align_left`, `text.align_center`, `text.align_right` |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_textalign Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_textalign(lb, "center")
}
```

## `label.set_textcolor` (function)

**Definition**

Sets a label's text color.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_textcolor(series label id, series color textcolor) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `textcolor` | `series color` | yes | Text color. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_textcolor Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_textcolor(lb, color.white)
}
```

## `label.set_tooltip` (function)

**Definition**

Sets a label's tooltip.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_tooltip(series label id, series string tooltip) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `tooltip` | `series string` | yes | Tooltip text. |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_tooltip Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_tooltip(lb, "Last close")
}
```

## `label.set_x` (function)

**Definition**

Sets a label's x-coordinate.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_x(series label id, series int x) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `x` | `series int` | yes | X-coordinate (bar index or time, depending on xloc). |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_x Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_x(lb, bar_index)
}
```

## `label.set_xloc` (function)

**Definition**

Sets whether a label's x-coordinate is a bar index or time.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_xloc(series label id, series int x, series string xloc) → void
```

**Parameters**

| Name | Type | Required | Description | Values |
| - | - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. | |
| `x` | `series int` | yes | X-coordinate (bar index or time, depending on xloc). | |
| `xloc` | `series string` | yes | xloc.bar\_index or xloc.bar\_time. | `xloc.bar_index`, `xloc.bar_time` |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_xloc Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_xloc(lb, bar_index, xloc.bar_index)
}
```

## `label.set_xy` (function)

**Definition**

Sets a label's x and y coordinates.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_xy(series label id, series int x, series float y) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `x` | `series int` | yes | X-coordinate (bar index or time, depending on xloc). |
| `y` | `series float` | yes | Y-coordinate (price). |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_xy Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_xy(lb, bar_index, close)
}
```

## `label.set_y` (function)

**Definition**

Sets a label's y-coordinate (price).

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_y(series label id, series float y) → void
```

**Parameters**

| Name | Type | Required | Description |
| - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. |
| `y` | `series float` | yes | Y-coordinate (price). |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_y Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_y(lb, close)
}
```

## `label.set_yloc` (function)

**Definition**

Sets a label's vertical location relative to the bar.

**Syntax**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
label.set_yloc(series label id, series string yloc) → void
```

**Parameters**

| Name | Type | Required | Description | Values |
| - | - | - | - | - |
| `id` | `series label` | yes | Drawing object to modify or query. | |
| `yloc` | `series string` | yes | Vertical location relative to the bar (yloc.price, etc.). | `yloc.abovebar`, `yloc.belowbar`, `yloc.price` |

**Returns**

`void`

void

**Example**

```lipi theme={"languages":{"custom":["/languages/lipi.json","/languages/lipi-invalid.json"]}}
//@lipi=2
indicator("label.set_yloc Example", overlay=true)
if barstate.islast {
    lb = label.new(bar_index, high, text="Hi", color=color.green)
    label.set_yloc(lb, yloc.price)
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.