Skip to content
ChartDeck ChartScript docs Account Open the terminal

tag

Level tags: a price shown as a name tag and a price tag at the right edge of the pane, with a line where chosen.

#Functions

#tag.auto_keepfunction

How many tag.place_auto tags on each side of the live price get their line (default 2, 0-6), for the whole script.

tag.auto_keep(n: int)
ParameterTypeDescription
nintAuto tags per side of the live price that get the line (0-6).

Example

ChartScriptFragmentOpen in editor
tag.auto_keep(3)

Since ChartScript 1

#tag.deletefunction

Removes the tag (na is ignored).

tag.delete(id: tag)
ParameterTypeDescription
idtagThe tag.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
if (barstate.islast) {
    t.delete()
}

Since ChartScript 1

#tag.get_placefunction

The placement the script set (tag.place_*).

tag.get_place(id: tag): string
ParameterTypeDescription
idtagThe tag.

Returns string.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
const p = t.get_place()

Since ChartScript 1

#tag.get_pricefunction

The price.

tag.get_price(id: tag): float
ParameterTypeDescription
idtagThe tag.

Returns float.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
const p = t.get_price()

Since ChartScript 1

#tag.get_textfunction

The name.

tag.get_text(id: tag): string
ParameterTypeDescription
idtagThe tag.

Returns string.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
const s = t.get_text()

Since ChartScript 1

#tag.newfunction

A level tag: the name in a filled tag inside the pane against the price axis and the price in the same colour on the axis, in one row with the other tags of the pane (pushed rows keep their price order). A tag off the visible prices is pinned at that edge. The member can change each titled tag's placement, line and colour in the Style tab, and switch all of a script's tags with "Level tags". 64 per script (32 on Beginner); the oldest is removed.

tag.new(price: float, text: string, { place?: string = tag.place_axis, color?: color = na, textcolor?: color = na, show_price?: bool = true, line_from?: int = na, line_to?: string = tag.line_to_tag, line_style?: string = line.style_solid, line_width?: int = 1, line_color?: color = na, tooltip?: string = "", title?: const string = "", size?: size = size.normal, xloc?: simple string = xloc.bar_index }): tag
ParameterTypeDescription
pricefloatThe price of the level; na hides the tag.
textstringThe name in the name tag (24 characters at most; longer is cut with "…"). The price has its own tag on the axis.
placestringdefault tag.place_axistag.place_chart (name, price and the line), tag.place_axis (name and price, no line), tag.place_off (nothing drawn, the tag is kept) or tag.place_auto (the line only while the tag is among the tag.auto_keep nearest above or below the live price).
colorcolordefault naThe fill of both tags and the line's colour (na: the chart's accent). The text is dark or white, whichever reads better.
textcolorcolordefault naThe text colour of both tags (na: dark or white by the fill).
show_pricebooldefault truetrue: the price tag on the axis in the same row; false: the name tag only.
line_fromintdefault naThe bar the line starts at (a bar index, or a time with xloc.bar_time); na: the pane's left edge.
line_tostringdefault tag.line_to_tagtag.line_to_tag: the line ends at the name tag; tag.line_to_bars: at the last bar (with line_from na: a stub from the last bar to the tag).
line_stylestringdefault line.style_solidline.style_solid, line.style_dashed, line.style_dotted or a dash.* pattern.
line_widthintdefault 1The line width, 1-4 px.
line_colorcolordefault naThe line colour when it differs from color.
tooltipstringdefault ""The hover text of both tags; the chart puts the name and the exact price first.
titleconst stringdefault ""A name for the Style tab: a titled tag gets its own Style row (placement, line, colour, price on the axis).
sizesizedefault size.normalsize.small (9 px) or size.normal (10 px).
xlocsimple stringdefault xloc.bar_indexHow line_from is read: xloc.bar_index or xloc.bar_time.

Returns tag.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Day open", { color: color.orange, place: tag.place_chart, tooltip: "The first price of the run", title: "Day open" })

Since ChartScript 1

#tag.set_colorfunction

Sets the colour of the tags and the line.

tag.set_color(id: tag, color: color)
ParameterTypeDescription
idtagThe tag.
colorcolorThe fill of both tags and the line's colour (na: the chart's accent). The text is dark or white, whichever reads better.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_color(close > open ? color.up : color.down)

Since ChartScript 1

#tag.set_line_colorfunction

Sets the line colour.

tag.set_line_color(id: tag, line_color: color)
ParameterTypeDescription
idtagThe tag.
line_colorcolorThe line colour when it differs from color.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open", { place: tag.place_chart })
t.set_line_color(color.gray)

Since ChartScript 1

#tag.set_line_fromfunction

Sets the bar the line starts at (na: the pane's left edge).

tag.set_line_from(id: tag, line_from: int, { xloc?: string = xloc.bar_index })
ParameterTypeDescription
idtagThe tag.
line_fromintThe bar the line starts at (a bar index, or a time with xloc.bar_time); na: the pane's left edge.
xlocstringdefault xloc.bar_indexHow line_from is read: xloc.bar_index or xloc.bar_time.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open", { place: tag.place_chart })
t.set_line_from(bar_index - 20)

Since ChartScript 1

#tag.set_line_stylefunction

Sets the line style (line.style_* or dash.*).

tag.set_line_style(id: tag, line_style: string)
ParameterTypeDescription
idtagThe tag.
line_stylestringline.style_solid, line.style_dashed, line.style_dotted or a dash.* pattern.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open", { place: tag.place_chart })
t.set_line_style(line.style_dashed)

Since ChartScript 1

#tag.set_line_tofunction

Sets where the line ends (tag.line_to_*).

tag.set_line_to(id: tag, line_to: string)
ParameterTypeDescription
idtagThe tag.
line_tostringtag.line_to_tag: the line ends at the name tag; tag.line_to_bars: at the last bar (with line_from na: a stub from the last bar to the tag).

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open", { place: tag.place_chart })
t.set_line_to(tag.line_to_bars)

Since ChartScript 1

#tag.set_line_widthfunction

Sets the line width (1-4 px).

tag.set_line_width(id: tag, line_width: int)
ParameterTypeDescription
idtagThe tag.
line_widthintThe line width, 1-4 px.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open", { place: tag.place_chart })
t.set_line_width(2)

Since ChartScript 1

#tag.set_placefunction

Sets the placement (tag.place_*); tag.place_off hides the tag and keeps it.

tag.set_place(id: tag, place: string)
ParameterTypeDescription
idtagThe tag.
placestringtag.place_chart (name, price and the line), tag.place_axis (name and price, no line), tag.place_off (nothing drawn, the tag is kept) or tag.place_auto (the line only while the tag is among the tag.auto_keep nearest above or below the live price).

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_place(tag.place_auto)

Since ChartScript 1

#tag.set_pricefunction

Sets the price (na hides the tag; the same as set_y).

tag.set_price(id: tag, price: float)
ParameterTypeDescription
idtagThe tag.
pricefloatThe price of the level; na hides the tag.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "High")
t.set_price(math.max(t.get_price(), high))

Since ChartScript 1

#tag.set_show_pricefunction

Shows or hides the price tag on the axis.

tag.set_show_price(id: tag, show_price: bool)
ParameterTypeDescription
idtagThe tag.
show_pricebooltrue: the price tag on the axis in the same row; false: the name tag only.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_show_price(false)

Since ChartScript 1

#tag.set_textfunction

Sets the name.

tag.set_text(id: tag, text: string)
ParameterTypeDescription
idtagThe tag.
textstringThe name in the name tag (24 characters at most; longer is cut with "…"). The price has its own tag on the axis.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_text("Open " + str.tostring(open))

Since ChartScript 1

#tag.set_textcolorfunction

Sets the text colour.

tag.set_textcolor(id: tag, textcolor: color)
ParameterTypeDescription
idtagThe tag.
textcolorcolorThe text colour of both tags (na: dark or white by the fill).

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_textcolor(color.white)

Since ChartScript 1

#tag.set_tooltipfunction

Sets the hover text.

tag.set_tooltip(id: tag, tooltip: string)
ParameterTypeDescription
idtagThe tag.
tooltipstringThe hover text of both tags; the chart puts the name and the exact price first.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Open")
t.set_tooltip("The first price of the run")

Since ChartScript 1

#tag.set_yfunction

Sets the price (na hides the tag).

tag.set_y(id: tag, price: float)
ParameterTypeDescription
idtagThe tag.
pricefloatThe price of the level; na hides the tag.

Example

ChartScriptFragmentOpen in editor
state t = tag.new(open, "Last")
t.set_y(close)

Since ChartScript 1

#Variables

#tag.allvariable

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

tag.all: array<tag>

Type series array<tag>.

Example

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

Since ChartScript 1

#Constants

NameTypeDescription
tag.line_to_barsstringThe line ends at the last bar.
tag.line_to_tagstringThe line ends at the name tag.
tag.place_autostringPlacement: the line only while the tag is among the tag.auto_keep nearest above or below the live price (decided by the chart as price moves).
tag.place_axisstringPlacement: the name and price tags, no line.
tag.place_chartstringPlacement: the name and price tags and the line.
tag.place_offstringPlacement: nothing drawn; the tag is kept.

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