label
Labels: text at a bar and a price.
#Functions
#label.copyfunction
A new label with the same properties.
label.copy(id: label): label| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Returns label.
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Example
const lb = label.new(bar_index, high)
lb.delete()Since ChartScript 1
#label.get_textfunction
The text.
label.get_text(id: label): string| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Returns string.
Example
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| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Returns string.
Example
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| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Returns int.
Example
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| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
Returns float.
Example
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 = "" }): labellabel.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| Parameter | Type | Description |
|---|---|---|
x | int | The value. |
y | float | The y. |
text | stringdefault "" | Text drawn with the shape. |
xloc | simple stringdefault xloc.bar_index | The xloc. |
yloc | stringdefault yloc.price | The yloc. |
color | colordefault color.blue | The colour. |
style | stringdefault label.style_label_down | The style constant. |
textcolor | colordefault color.white | The colour of the text. |
size | stringdefault size.normal | The number of elements. |
textalign | stringdefault text.align_center | The textalign. |
tooltip | stringdefault "" | Help text shown next to the input. |
text_font_family | stringdefault font.family_default | The text font family. |
force_overlay | const booldefault false | Accepted and ignored in this version. |
text_formatting | intdefault text.format_none | The text formatting. |
look | const 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). |
point | point | The point. |
Returns label.
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
color | color | The colour. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
point | point | The point. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
size | string | The number of elements. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
style | string | The style constant. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
text | string | Text drawn with the shape. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
text_font_family | string | The text font family. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
text_formatting | int | The text formatting. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
textalign | string | The textalign. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
textcolor | color | The colour of the text. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
tooltip | string | Help text shown next to the input. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
x | int | The value. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
x | int | The value. |
xloc | string | The xloc. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
x | int | The value. |
y | float | The y. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
y | float | The y. |
Example
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)| Parameter | Type | Description |
|---|---|---|
id | label | The array. |
yloc | string | The yloc. |
Example
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
const n = array.size(label.all)Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
label.style_arrowdown | string | Label shape. |
label.style_arrowup | string | Label shape. |
label.style_circle | string | Label shape. |
label.style_cross | string | Label shape. |
label.style_diamond | string | Label shape. |
label.style_flag | string | Label shape. |
label.style_label_center | string | Label shape. |
label.style_label_down | string | Label shape. |
label.style_label_left | string | Label shape. |
label.style_label_lower_left | string | Label shape. |
label.style_label_lower_right | string | Label shape. |
label.style_label_right | string | Label shape. |
label.style_label_up | string | Label shape. |
label.style_label_upper_left | string | Label shape. |
label.style_label_upper_right | string | Label shape. |
label.style_labeldown | string | Label shape. |
label.style_labelup | string | Label shape. |
label.style_none | string | Label shape. |
label.style_square | string | Label shape. |
label.style_text_outline | string | Label shape. |
label.style_triangledown | string | Label shape. |
label.style_triangleup | string | Label shape. |
label.style_xcross | string | Label shape. |