Skip to content

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

NameTypeDefaultDescription
pointseries chart.pointThe chart.point object specifying the position of the label.
textseries string""The text to display on the label.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
ylocseries stringyloc.priceThe y-location type: yloc.price or yloc.price_range.
colorseries colornaThe background color of the label.
styleseries stringstyle_label_downThe style of the label.
textcolorseries colornaThe color of the label text.
sizeseries stringsize.normalThe size of the label as a named constant.
textalignseries stringtext.align_centerThe text alignment: text.align_center, text.align_left, or text.align_right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries stringfont.family_defaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst text_formattext.format_noneThe text formatting options.

Returns: series label

Creates a label object on the chart.

Parameters

NameTypeDefaultDescription
pointseries chart.pointThe chart.point object specifying the position of the label.
textseries string""The text to display on the label.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
ylocseries stringyloc.priceThe y-location type: yloc.price or yloc.price_range.
colorseries colornaThe background color of the label.
styleseries stringstyle_label_downThe style of the label.
textcolorseries colornaThe color of the label text.
sizeseries int0The size of the label as an integer value.
textalignseries stringtext.align_centerThe text alignment: text.align_center, text.align_left, or text.align_right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries stringfont.family_defaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst text_formattext.format_noneThe text formatting options.

Returns: series label

Creates a label object on the chart.

Parameters

NameTypeDefaultDescription
xseries intThe x-coordinate (bar index or UNIX time).
yseries floatThe y-coordinate (price).
textseries string""The text to display on the label.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
ylocseries stringyloc.priceThe y-location type: yloc.price or yloc.price_range.
colorseries colornaThe background color of the label.
styleseries stringstyle_label_downThe style of the label.
textcolorseries colornaThe color of the label text.
sizeseries stringsize.normalThe size of the label as a named constant.
textalignseries stringtext.align_centerThe text alignment: text.align_center, text.align_left, or text.align_right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries stringfont.family_defaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst text_formattext.format_noneThe text formatting options.

Returns: series label

Creates a label object on the chart.

Parameters

NameTypeDefaultDescription
xseries intThe x-coordinate (bar index or UNIX time).
yseries floatThe y-coordinate (price).
textseries string""The text to display on the label.
xlocseries stringxloc.bar_indexThe x-location type: xloc.bar_index or xloc.bar_time.
ylocseries stringyloc.priceThe y-location type: yloc.price or yloc.price_range.
colorseries colornaThe background color of the label.
styleseries stringstyle_label_downThe style of the label.
textcolorseries colornaThe color of the label text.
sizeseries int0The size of the label as an integer value.
textalignseries stringtext.align_centerThe text alignment: text.align_center, text.align_left, or text.align_right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries stringfont.family_defaultThe font family for the label text.
force_overlayseries boolfalseIf true, the label is rendered on the top.
text_formattingconst text_formattext.format_noneThe text formatting options.

Returns: series label

Methods

copy

pine
label.copy(series label id) → series label

Creates a copy of the specified label and returns its id.

Parameters

NameTypeDefaultDescription
idseries labelThe label to copy.

Returns: series label


delete

pine
label.delete(series label id)

Deletes the specified label from the chart.

Parameters

NameTypeDefaultDescription
idseries labelThe label to delete.

get_text

pine
label.get_text(series label id) → series string

Returns text of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to get the text from.

Returns: series string


get_x

pine
label.get_x(series label id) → series int

Returns UNIX time or bar index (depending on the last xloc value set) of this label's position.

Parameters

NameTypeDefaultDescription
idseries labelThe label to get the x-coordinate from.

Returns: series int


get_y

pine
label.get_y(series label id) → series float

Returns price of this label's position.

Parameters

NameTypeDefaultDescription
idseries labelThe label to get the y-coordinate from.

Returns: series float


set_color

pine
label.set_color(series label id, series color color)

Sets color of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
colorseries colorThe new background color.

set_point

pine
label.set_point(series label id, series chart.point point)

Sets the location of this label using a chart.point object.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
pointseries chart.pointThe chart.point object specifying the new position.

set_size

Sets arrow and text size of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
sizeseries intThe new size as an integer value.

Sets arrow and text size of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
sizeseries stringThe new size as a named constant (size.tiny, size.small, size.normal, size.large, size.huge).

set_style

pine
label.set_style(series label id, series string style)

Sets style of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
styleseries stringThe new label style constant.

set_text

pine
label.set_text(series label id, series string text)

Sets text of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
textseries stringThe new text to display.

set_text_font_family

pine
label.set_text_font_family(series label id, series string text_font_family)

Sets font family of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
text_font_familyseries stringThe font family: font.family_default or font.family_monospace.

set_text_formatting

pine
label.set_text_formatting(series label id, const text_format text_formatting)

Sets text formatting of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
text_formattingconst text_formatThe text formatting options.

set_textalign

pine
label.set_textalign(series label id, series string textalign)

Sets text alignment of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
textalignseries stringThe text alignment: text.align_center, text.align_left, or text.align_right.

set_textcolor

pine
label.set_textcolor(series label id, series color textcolor)

Sets text color of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
textcolorseries colorThe new text color.

set_tooltip

pine
label.set_tooltip(series label id, series string tooltip)

Sets tooltip text of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
tooltipseries stringThe new tooltip text.

set_x

pine
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

NameTypeDefaultDescription
idseries labelThe label to modify.
xseries intThe new x-coordinate (bar index or UNIX time).

set_xloc

pine
label.set_xloc(series label id, series string xloc)

Sets x location type of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
xlocseries stringThe x-location type: xloc.bar_index or xloc.bar_time.

set_xy

pine
label.set_xy(series label id, series int x, series float y)

Sets both x and y coordinates of this label's position.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
xseries intThe new x-coordinate (bar index or UNIX time).
yseries floatThe new y-coordinate (price).

set_y

pine
label.set_y(series label id, series float y)

Sets price of this label's position.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
yseries floatThe new y-coordinate (price).

set_yloc

pine
label.set_yloc(series label id, series string yloc)

Sets y location type of this label.

Parameters

NameTypeDefaultDescription
idseries labelThe label to modify.
ylocseries stringThe y-location type: yloc.price or yloc.price_range.

基於 MIT 許可證發佈。