Skip to content

Label

Handle for a label drawing.

Static Methods

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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
ylocseries YlocYloc.PriceThe y-location type: Yloc.Price or Yloc.Price_range.
colorseries colornaThe background color of the label.
styleseries LabelStyleLabelStyle.DownThe style of the label.
text_colorseries colornaThe color of the label text.
sizeseries SizeSize.NormalThe size of the label as a named constant.
textalignseries TextHAlignTextHAlign.CenterThe text alignment: TextHAlign.Center, TextHAlign.Left, or TextHAlign.Right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst TextFormattext.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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
ylocseries YlocYloc.PriceThe y-location type: Yloc.Price or Yloc.Price_range.
colorseries colornaThe background color of the label.
styleseries LabelStyleLabelStyle.DownThe style of the label.
text_colorseries colornaThe color of the label text.
sizeseries int0The size of the label as an integer value.
textalignseries TextHAlignTextHAlign.CenterThe text alignment: TextHAlign.Center, TextHAlign.Left, or TextHAlign.Right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst TextFormattext.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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
ylocseries YlocYloc.PriceThe y-location type: Yloc.Price or Yloc.Price_range.
colorseries colornaThe background color of the label.
styleseries LabelStyleLabelStyle.DownThe style of the label.
text_colorseries colornaThe color of the label text.
sizeseries SizeSize.NormalThe size of the label as a named constant.
textalignseries TextHAlignTextHAlign.CenterThe text alignment: TextHAlign.Center, TextHAlign.Left, or TextHAlign.Right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the label text.
force_overlayconst boolfalseIf true, the label is rendered on the top.
text_formattingconst TextFormattext.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 XlocXloc.BarIndexThe x-location type: Xloc.BarIndex or Xloc.BarTime.
ylocseries YlocYloc.PriceThe y-location type: Yloc.Price or Yloc.Price_range.
colorseries colornaThe background color of the label.
styleseries LabelStyleLabelStyle.DownThe style of the label.
text_colorseries colornaThe color of the label text.
sizeseries int0The size of the label as an integer value.
textalignseries TextHAlignTextHAlign.CenterThe text alignment: TextHAlign.Center, TextHAlign.Left, or TextHAlign.Right.
tooltipseries stringnaThe tooltip text when hovering over the label.
text_font_familyseries FontFamilyFontFamily.DefaultThe font family for the label text.
force_overlayseries boolfalseIf true, the label is rendered on the top.
text_formattingconst TextFormattext.NONEThe text formatting options.

Returns: series Label

Static Properties

all

Type: series Array<Label>

Returns an array filled with all the current labels drawn by the script.

Methods

copy

navi
Label.copy(id: series Label): series Label

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

Parameters

NameTypeDefaultDescription
idseries LabelThe label to copy.

Returns: series Label


delete

navi
Label.delete(id: series Label)

Deletes the specified label from the chart.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to delete.

get_text

navi
Label.get_text(id: series Label): series string

Returns text of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to get the text from.

Returns: series string


get_x

navi
Label.get_x(id: series Label): 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

navi
Label.get_y(id: series Label): 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

navi
Label.set_color(id: series Label, color: series color)

Sets color of this label.

Parameters

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

set_point

navi
Label.set_point(id: series Label, point: series chart.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 SizeThe new size as a named constant (Size.Tiny, Size.Small, Size.Normal, Size.Large, Size.Huge).

set_style

navi
Label.set_style(id: series Label, style: series LabelStyle)

Sets style of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
styleseries LabelStyleThe new label style constant.

set_text

navi
Label.set_text(id: series Label, text: series string)

Sets text of this label.

Parameters

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

set_text_font_family

navi
Label.set_text_font_family(
    id: series Label,
    text_font_family: series FontFamily
  )

Sets font family of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
text_font_familyseries FontFamilyThe font family: FontFamily.Default or FontFamily.Monospace.

set_text_formatting

navi
Label.set_text_formatting(id: series Label, text_formatting: const TextFormat)

Sets text formatting of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
text_formattingconst TextFormatThe text formatting options.

set_textalign

navi
Label.set_textalign(id: series Label, textalign: series TextHAlign)

Sets text alignment of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
textalignseries TextHAlignThe text alignment: TextHAlign.Center, TextHAlign.Left, or TextHAlign.Right.

set_textcolor

navi
Label.set_textcolor(id: series Label, text_color: series color)

Sets text color of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
text_colorseries colorThe new text color.

set_tooltip

navi
Label.set_tooltip(id: series Label, tooltip: series string)

Sets tooltip text of this label.

Parameters

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

set_x

navi
Label.set_x(id: series Label, x: series int)

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

navi
Label.set_xloc(id: series Label, xloc: series Xloc)

Sets x location type of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
xlocseries XlocThe x-location type: Xloc.BarIndex or Xloc.BarTime.

set_xy

navi
Label.set_xy(id: series Label, x: series int, y: series float)

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

navi
Label.set_y(id: series Label, y: series float)

Sets price of this label's position.

Parameters

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

set_yloc

navi
Label.set_yloc(id: series Label, yloc: series Yloc)

Sets y location type of this label.

Parameters

NameTypeDefaultDescription
idseries LabelThe label to modify.
ylocseries YlocThe y-location type: Yloc.Price or Yloc.Price_range.

Released under the MIT License.