Skip to content
ChartDeck ChartScript docs Account Open the terminal

style

Named, user-editable styles for plots, shapes, fills and levels (ChartDeck extra).

#Functions

#style.boxfunction

A named box style: box.new takes it with { look: … }, and the member restyles every drawing that uses it at once.

style.box(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const st = style.box("Boxs")

Since ChartScript 1

#style.cellfunction

A named cell style: table.cell takes it with { look: … }, and the member restyles every drawing that uses it at once.

style.cell(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const st = style.cell("Cells")

Since ChartScript 1

#style.fillfunction

A named fill style (colour, opacity).

style.fill(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const fs = style.fill("Band", { color: color.accent, opacity: 20 })
const a = plot(high)
const b = plot(low)
fill(a, b, { look: fs })

Since ChartScript 1

#style.labelfunction

A named label style: label.new takes it with { look: … }, and the member restyles every drawing that uses it at once.

style.label(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const st = style.label("Labels")

Since ChartScript 1

#style.linefunction

A named line style (colour, width, dash, cap, opacity); levels and plots take it with { look: … }.

style.line(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const lv = style.line("Levels", { color: color.muted, width: 1, dash: dash.dotted })
hline(50, "Mid", { look: lv })

Since ChartScript 1

#style.markerfunction

A named marker style for plotshape / plotchar (shape, size, colour, text).

style.marker(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const mk = style.marker("Signals", { size: size.small, color: color.up })
plotshape(close > open, "Up", { look: mk })

Since ChartScript 1

#style.plotfunction

A named plot style (colour, width, dash, plot type, area opacity); plots take it with { look: … }.

style.plot(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const lk = style.plot("Averages", { width: 2 })
plot(ta.sma(close, 20), "SMA", { look: lk })

Since ChartScript 1

#style.tablefunction

A named table style: table.new takes it with { look: … }, and the member restyles every drawing that uses it at once.

style.table(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const st = style.table("Tables")

Since ChartScript 1

#style.textfunction

A named text style (size, font, weight, italic, colour, halo, background, padding, wrap ...).

style.text(title: const string, values: const T, …): string
ParameterTypeDescription
titleconst stringThe name shown on the Style tab.
valuesconst Tproperty: value pairs in an options object (color, width, dash, size, font, section, id, expose, lock, role ...). section: the heading the style is listed under on the Style and Colors tabs (the title of a settings.section merges with it). role: what the color of the style means for the color presets ("up", "down", "neutral", "accent"); the role of an output itself wins.

Returns string.

Example

ChartScriptFragmentOpen in editor
const tx = style.text("Labels", { size: size.pt(9), weight: 600 })

Since ChartScript 1

#style.variantfunction

A variant of a style (bull / bear colours ...): each variant is a user swatch; a call picks it with { variant: … }.

style.variant(look: const string, name: const string, values: const T, …)
ParameterTypeDescription
lookconst stringThe style.
nameconst stringThe variant name (letters, digits, _).
valuesconst Tproperty: value pairs in an options object.

Example

ChartScriptFragmentOpen in editor
const lv = style.line("Levels", { color: color.muted })
style.variant(lv, "bull", { color: color.up })
hline(70, "Top", { look: lv, variant: "bull" })

Since ChartScript 1

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