Skip to content
ChartDeck ChartScript docs Account Open the terminal

legend

Items the script shows in its legend row after its name: text, colour keys and badges, from the newest bar.

#Functions

#legend.badgefunction

Shows a small outlined badge at the end of the legend row, such as "Model estimate".

legend.badge(text: string, { tooltip?: string = "", warn?: bool = false })
ParameterTypeDescription
textstringThe badge text.
tooltipstringdefault ""Text shown under the pointer.
warnbooldefault falsetrue = in the warning colour.

Example

ChartScriptFragmentOpen in editor
legend.badge("Model estimate", "Model estimate, not exchange data.")

Since ChartScript 1

#legend.infofunction

Shows text in the legend row after the script name (from the newest bar). At most 24 items a script.

legend.info(text: string, { tooltip?: string = "", warn?: bool = false, priority?: int = 2 })
ParameterTypeDescription
textstringThe text (at most 120 characters).
tooltipstringdefault ""Text shown under the pointer.
warnbooldefault falsetrue = in the warning colour.
priorityintdefault 21 = always kept; 2; 3 = dropped first when the row is too narrow.

Example

ChartScriptFragmentOpen in editor
if (barstate.islast) {
    legend.info("updated " + str.format_time(timenow, "HH:mm") + " UTC")
}

Since ChartScript 1

#legend.keyfunction

Shows a colour key in the legend row: a swatch and its text.

legend.key(text: string, { color?: color = na, palette?: string = "", dashed?: bool = false, group?: string = "", priority?: int = 3 })
ParameterTypeDescription
textstringThe text.
colorcolordefault naThe swatch colour.
palettestringdefault ""A heatmap palette (heatmap.palette_*): the swatch shows its gradient.
dashedbooldefault falsetrue = a dashed swatch.
groupstringdefault ""Keys with the same group are dropped together on a narrow row.
priorityintdefault 31 = always kept; 3 = dropped first.

Example

ChartScriptFragmentOpen in editor
legend.key("longs", color.up)
legend.key("$1M+ per level", na, heatmap.palette_heat)

Since ChartScript 1

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