label
Properties
all
Type: series array<label>
Returns an array filled with all the current labels drawn by the script.
style_arrowdown
Type: const string
Label style for label.new() and label.set_style() functions.
style_arrowup
Type: const string
Label style for label.new() and label.set_style() functions.
style_circle
Type: const string
Label style for label.new() and label.set_style() functions.
style_cross
Type: const string
Label style for label.new() and label.set_style() functions.
style_diamond
Type: const string
Label style for label.new() and label.set_style() functions.
style_flag
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_center
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_down
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_left
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_lower_left
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_lower_right
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_right
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_up
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_upper_left
Type: const string
Label style for label.new() and label.set_style() functions.
style_label_upper_right
Type: const string
Label style for label.new() and label.set_style() functions.
style_square
Type: const string
Label style for label.new() and label.set_style() functions.
style_text_outline
Type: const string
Label style for label.new() and label.set_style() functions.
style_triangle_down
Type: const string
Label style for label.new() and label.set_style() functions.
style_triangle_up
Type: const string
Label style for label.new() and label.set_style() functions.
style_xcross
Type: const string
Label style for label.new() and label.set_style() functions.
Functions
new
Creates a label object on the chart.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
point | series chart.point | The chart.point object specifying the position of the label. | |
text | series string | "" | The text to display on the label. |
xloc | series string | xloc.bar_index | The x-location type: xloc.bar_index or xloc.bar_time. |
yloc | series string | yloc.price | The y-location type: yloc.price or yloc.price_range. |
color | series color | na | The background color of the label. |
style | series string | style_label_down | The style of the label. |
textcolor | series color | na | The color of the label text. |
size | series string | size.normal | The size of the label as a named constant. |
textalign | series string | text.align_center | The text alignment: text.align_center, text.align_left, or text.align_right. |
tooltip | series string | na | The tooltip text when hovering over the label. |
text_font_family | series string | font.family_default | The font family for the label text. |
force_overlay | const bool | false | If true, the label is rendered on the top. |
text_formatting | const text_format | text.format_none | The text formatting options. |
Returns: series label
Methods
copy
label.copy(series label id) → series labelCreates a copy of the specified label and returns its id.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to copy. |
Returns: series label
delete
label.delete(series label id)Deletes the specified label from the chart.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to delete. |
get_text
label.get_text(series label id) → series stringReturns text of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to get the text from. |
Returns: series string
get_x
label.get_x(series label id) → series intReturns UNIX time or bar index (depending on the last xloc value set) of this label's position.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to get the x-coordinate from. |
Returns: series int
get_y
label.get_y(series label id) → series floatReturns price of this label's position.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to get the y-coordinate from. |
Returns: series float
set_color
label.set_color(series label id, series color color)Sets color of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
color | series color | The new background color. |
set_point
label.set_point(series label id, series chart.point point)Sets the location of this label using a chart.point object.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
point | series chart.point | The chart.point object specifying the new position. |
set_size
Sets arrow and text size of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
size | series int | The new size as an integer value. |
set_style
label.set_style(series label id, series string style)Sets style of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
style | series string | The new label style constant. |
set_text
label.set_text(series label id, series string text)Sets text of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
text | series string | The new text to display. |
set_text_font_family
label.set_text_font_family(series label id, series string text_font_family)Sets font family of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
text_font_family | series string | The font family: font.family_default or font.family_monospace. |
set_text_formatting
label.set_text_formatting(series label id, const text_format text_formatting)Sets text formatting of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
text_formatting | const text_format | The text formatting options. |
set_textalign
label.set_textalign(series label id, series string textalign)Sets text alignment of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
textalign | series string | The text alignment: text.align_center, text.align_left, or text.align_right. |
set_textcolor
label.set_textcolor(series label id, series color textcolor)Sets text color of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
textcolor | series color | The new text color. |
set_tooltip
label.set_tooltip(series label id, series string tooltip)Sets tooltip text of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
tooltip | series string | The new tooltip text. |
set_x
label.set_x(series label id, series int x)Sets UNIX time or bar index (depending on the last xloc value set) of this label's position.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
x | series int | The new x-coordinate (bar index or UNIX time). |
set_xloc
label.set_xloc(series label id, series string xloc)Sets x location type of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
xloc | series string | The x-location type: xloc.bar_index or xloc.bar_time. |
set_xy
label.set_xy(series label id, series int x, series float y)Sets both x and y coordinates of this label's position.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
x | series int | The new x-coordinate (bar index or UNIX time). | |
y | series float | The new y-coordinate (price). |
set_y
label.set_y(series label id, series float y)Sets price of this label's position.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
y | series float | The new y-coordinate (price). |
set_yloc
label.set_yloc(series label id, series string yloc)Sets y location type of this label.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
id | series label | The label to modify. | |
yloc | series string | The y-location type: yloc.price or yloc.price_range. |