Skip to content
ChartDeck ChartScript docs Account Open the terminal

label

Labels: text at a bar and a price.

#Functions

#label.copyfunction

A new label with the same properties.

label.copy(id: label): label
ParameterTypeDescription
idlabelThe array.

Returns label.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
const l2 = lb.copy()

Since ChartScript 1

#label.deletefunction

Removes the label (na is ignored).

label.delete(id: label)
ParameterTypeDescription
idlabelThe array.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.delete()

Since ChartScript 1

#label.get_textfunction

The text.

label.get_text(id: label): string
ParameterTypeDescription
idlabelThe array.

Returns string.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high, "a")
const v = lb.get_text()

Since ChartScript 1

#label.get_tooltipfunction

The hover text (ChartScript extra).

label.get_tooltip(id: label): string
ParameterTypeDescription
idlabelThe array.

Returns string.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high, "a")
const v = lb.get_tooltip()

Since ChartScript 1

#label.get_xfunction

The bar (index or time).

label.get_x(id: label): int
ParameterTypeDescription
idlabelThe array.

Returns int.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high, "a")
const v = lb.get_x()

Since ChartScript 1

#label.get_yfunction

The price.

label.get_y(id: label): float
ParameterTypeDescription
idlabelThe array.

Returns float.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high, "a")
const v = lb.get_y()

Since ChartScript 1

#label.newfunction

A label at (x, y): a bar index (or a time with xloc.bar_time) and a price. The oldest is removed past max_labels_count.

label.new(x: int, y: float, { text?: string = "", xloc?: simple string = xloc.bar_index, yloc?: string = yloc.price, color?: color = color.blue, style?: string = label.style_label_down, textcolor?: color = color.white, size?: string = size.normal, textalign?: string = text.align_center, tooltip?: string = "", text_font_family?: string = font.family_default, force_overlay?: const bool = false, text_formatting?: int = text.format_none, look?: const string = "" }): label
label.new(point: point, { text?: string = "", xloc?: simple string = xloc.bar_index, yloc?: string = yloc.price, color?: color = color.blue, style?: string = label.style_label_down, textcolor?: color = color.white, size?: string = size.normal, textalign?: string = text.align_center, tooltip?: string = "", text_font_family?: string = font.family_default, force_overlay?: const bool = false, text_formatting?: int = text.format_none, look?: const string = "" }): label
ParameterTypeDescription
xintThe value.
yfloatThe y.
textstringdefault ""Text drawn with the shape.
xlocsimple stringdefault xloc.bar_indexThe xloc.
ylocstringdefault yloc.priceThe yloc.
colorcolordefault color.blueThe colour.
stylestringdefault label.style_label_downThe style constant.
textcolorcolordefault color.whiteThe colour of the text.
sizestringdefault size.normalThe number of elements.
textalignstringdefault text.align_centerThe textalign.
tooltipstringdefault ""Help text shown next to the input.
text_font_familystringdefault font.family_defaultThe text font family.
force_overlayconst booldefault falseAccepted and ignored in this version.
text_formattingintdefault text.format_noneThe text formatting.
lookconst stringdefault ""A style made with style.label (its look, shared and user-editable). Without one the drawing still follows the Labels & text tab (size, font, dimming).
pointpointThe point.

Returns label.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high, "Hi")

Since ChartScript 1

#label.set_colorfunction

Sets the background colour.

label.set_color(id: label, color: color)
ParameterTypeDescription
idlabelThe array.
colorcolorThe colour.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_color(color.red)

Since ChartScript 1

#label.set_pointfunction

Moves the label to a chart.point.

label.set_point(id: label, point: point)
ParameterTypeDescription
idlabelThe array.
pointpointThe point.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_point(chart.point.now(low))

Since ChartScript 1

#label.set_sizefunction

Sets the text size.

label.set_size(id: label, size: string)
ParameterTypeDescription
idlabelThe array.
sizestringThe number of elements.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_size(size.small)

Since ChartScript 1

#label.set_stylefunction

Sets the shape (label.style_*).

label.set_style(id: label, style: string)
ParameterTypeDescription
idlabelThe array.
stylestringThe style constant.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_style(label.style_label_up)

Since ChartScript 1

#label.set_textfunction

Sets the text.

label.set_text(id: label, text: string)
ParameterTypeDescription
idlabelThe array.
textstringText drawn with the shape.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_text("x")

Since ChartScript 1

#label.set_text_font_familyfunction

Sets the font (font.family_default / font.family_monospace).

label.set_text_font_family(id: label, text_font_family: string)
ParameterTypeDescription
idlabelThe array.
text_font_familystringThe text font family.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_text_font_family(font.family_monospace)

Since ChartScript 1

#label.set_text_formattingfunction

Bold / italic (text.format_*).

label.set_text_formatting(id: label, text_formatting: int)
ParameterTypeDescription
idlabelThe array.
text_formattingintThe text formatting.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_text_formatting(text.format_bold)

Since ChartScript 1

#label.set_textalignfunction

Sets the text alignment (text.align_*).

label.set_textalign(id: label, textalign: string)
ParameterTypeDescription
idlabelThe array.
textalignstringThe textalign.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_textalign(text.align_left)

Since ChartScript 1

#label.set_textcolorfunction

Sets the text colour.

label.set_textcolor(id: label, textcolor: color)
ParameterTypeDescription
idlabelThe array.
textcolorcolorThe colour of the text.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_textcolor(color.white)

Since ChartScript 1

#label.set_tooltipfunction

Sets the hover text.

label.set_tooltip(id: label, tooltip: string)
ParameterTypeDescription
idlabelThe array.
tooltipstringHelp text shown next to the input.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_tooltip("t")

Since ChartScript 1

#label.set_xfunction

Moves the label to another bar (index or time).

label.set_x(id: label, x: int)
ParameterTypeDescription
idlabelThe array.
xintThe value.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_x(bar_index)

Since ChartScript 1

#label.set_xlocfunction

Sets x and how it is read (xloc.bar_index or xloc.bar_time).

label.set_xloc(id: label, x: int, xloc: string)
ParameterTypeDescription
idlabelThe array.
xintThe value.
xlocstringThe xloc.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_xloc(time, xloc.bar_time)

Since ChartScript 1

#label.set_xyfunction

Sets the bar and the price.

label.set_xy(id: label, x: int, y: float)
ParameterTypeDescription
idlabelThe array.
xintThe value.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_xy(bar_index, low)

Since ChartScript 1

#label.set_yfunction

Sets the price.

label.set_y(id: label, y: float)
ParameterTypeDescription
idlabelThe array.
yfloatThe y.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_y(low)

Since ChartScript 1

#label.set_ylocfunction

Sets yloc.price, yloc.abovebar or yloc.belowbar.

label.set_yloc(id: label, yloc: string)
ParameterTypeDescription
idlabelThe array.
ylocstringThe yloc.

Example

ChartScriptFragmentOpen in editor
const lb = label.new(bar_index, high)
lb.set_yloc(yloc.abovebar)

Since ChartScript 1

#Variables

#label.allvariable

Every label of the script that still exists, oldest first.

label.all: array<label>

Type series array<label>.

Example

ChartScriptFragmentOpen in editor
const n = array.size(label.all)

Since ChartScript 1

#Constants

NameTypeDescription
label.style_arrowdownstringLabel shape.
label.style_arrowupstringLabel shape.
label.style_circlestringLabel shape.
label.style_crossstringLabel shape.
label.style_diamondstringLabel shape.
label.style_flagstringLabel shape.
label.style_label_centerstringLabel shape.
label.style_label_downstringLabel shape.
label.style_label_leftstringLabel shape.
label.style_label_lower_leftstringLabel shape.
label.style_label_lower_rightstringLabel shape.
label.style_label_rightstringLabel shape.
label.style_label_upstringLabel shape.
label.style_label_upper_leftstringLabel shape.
label.style_label_upper_rightstringLabel shape.
label.style_labeldownstringLabel shape.
label.style_labelupstringLabel shape.
label.style_nonestringLabel shape.
label.style_squarestringLabel shape.
label.style_text_outlinestringLabel shape.
label.style_triangledownstringLabel shape.
label.style_triangleupstringLabel shape.
label.style_xcrossstringLabel shape.

The ChartScript documentation is in English for now; translations will follow.