Skip to content
ChartDeck ChartScript docs Account Open the terminal

settings

The settings dialog: tabs, sections, rows, notes, checks, presets, migrations (ChartDeck extra). Its tabs: your tabs (else Inputs), Colors, Style, Labels & text, Visibility.

#Functions

#settings.convertedfunction

Migration: saved numbers are converted (value x multiply + add).

settings.converted(name: const string, since: const int, { multiply?: const float = 1, add?: const float = 0 })
ParameterTypeDescription
nameconst stringThe name.
sinceconst intThe since.
multiplyconst floatdefault 1The factor.
addconst floatdefault 0Added after the factor.

Example

ChartScriptFragmentOpen in editor
const len = input.float(1.5, "Hours")
settings.converted("len", 2, { multiply: 1.0 / 60 })

Since ChartScript 1

#settings.defaultsfunction

Script-wide style defaults (text size, font, weight, line width, dash) under every style of the script. The Labels & text size switch of the settings dialog scales them.

settings.defaults(values: const T, …)
ParameterTypeDescription
valuesconst Tproperty: value pairs in an options object.

Example

ChartScriptFragmentOpen in editor
settings.defaults({ size: size.pt(10), font: font.mono })

Since ChartScript 1

#settings.end_rowfunction

Ends the current row.

settings.end_row()

Example

ChartScriptFragmentOpen in editor
settings.row("r", "Pair")
const a = input.int(1, "A")
settings.end_row()

Since ChartScript 1

#settings.notefunction

A plain-text help block between inputs.

settings.note(text: const string, { kind?: const string = "info" })
ParameterTypeDescription
textconst stringThe note (plain text, no links).
kindconst stringdefault "info""info" or "warning".

Example

ChartScriptFragmentOpen in editor
settings.note("Lengths are in bars of the chart timeframe.")

Since ChartScript 1

#settings.presetfunction

An author preset: named input values the user can apply in one click (listed above the user's templates).

settings.preset(name: const string, description?: const string = "", tf?: const string = "", default?: const bool = false, values: const T, …)
ParameterTypeDescription
nameconst stringThe preset name.
descriptionconst stringdefault ""One line shown under the name.
tfconst stringdefault ""Timeframes it suits ("m1-15", the Visibility encoding).
defaultconst booldefault falseApply automatically to a fresh instance on a matching timeframe.
valuesconst Tinput: value pairs in an options object, by the input's variable name ({ len: 9 }).

Example

ChartScriptFragmentOpen in editor
const len = input.int(20, "Length")
settings.preset("Scalping", { description: "Short lookback", len: 9 })

Since ChartScript 1

#settings.preset_stylefunction

The style part of a preset: property values for one style.

settings.preset_style(name: const string, look: const string, values: const T, …)
ParameterTypeDescription
nameconst stringThe name.
lookconst stringThe style (made with style.*).
valuesconst Tproperty: value pairs in an options object.

Example

ChartScriptFragmentOpen in editor
const lv = style.line("Levels", { width: 2 })
settings.preset_style("Clean", lv, { width: 1 })

Since ChartScript 1

#settings.remapfunction

Migration: saved option values change (old1, new1, old2, new2 ...).

settings.remap(name: const string, since: const int, pairs: const T, …)
ParameterTypeDescription
nameconst stringThe name.
sinceconst intThe since.
pairsconst TOld value, new value, ...

Example

ChartScriptFragmentOpen in editor
const mode = input.string("Fast", "Mode", { options: ["Fast", "Slow"] })
settings.remap("mode", 3, "Quick", "Fast")

Since ChartScript 1

#settings.renamedfunction

Migration: the input name was "was" before script version since; saved values move to the new name.

settings.renamed(name: const string, was: const string, since: const int)
ParameterTypeDescription
nameconst stringThe input's variable name now.
wasconst stringIts name before.
sinceconst intThe script version that renamed it.

Example

ChartScriptFragmentOpen in editor
const len = input.int(20, "Length")
settings.renamed("len", { was: "lookback", since: 4 })

Since ChartScript 1

#settings.renamed_outputfunction

Migration: an output or style id changed; saved style overrides move to it.

settings.renamed_output(id: const string, was: const string, since: const int)
ParameterTypeDescription
idconst stringThe output or style id now (p_..., y_...).
wasconst stringThe id before.
sinceconst intThe since.

Example

ChartScriptFragmentOpen in editor
plot(close, "Close")
settings.renamed_output("p_Close", { was: "p_Last", since: 2 })

Since ChartScript 1

#settings.retiredfunction

Migration: the input was removed in this version; saved values are kept for a while, then dropped.

settings.retired(name: const string, since: const int)
ParameterTypeDescription
nameconst stringThe name.
sinceconst intThe since.

Example

ChartScriptFragmentOpen in editor
settings.retired("oldSmoothing", 5)

Since ChartScript 1

#settings.rowfunction

Starts a labeled row: the next inputs share it, side by side (until settings.end_row, a row or a section). The same as giving the inputs one inline text.

settings.row(id: const string, { title?: const string = "", visible_if?: simple bool = true })
ParameterTypeDescription
idconst stringA stable id (letters, digits, _).
titleconst stringdefault ""The name shown in the settings, legend and data window.
visible_ifsimple booldefault trueThe visible if.

Example

ChartScriptFragmentOpen in editor
settings.row("poc", "POC")
const showPoc = input.bool(true, "Show")
const pocColor = input.color(color.accent, "Colour")
settings.end_row()

Since ChartScript 1

#settings.sectionfunction

Starts a section of the current tab, with reset, a "changed" count and help. The inputs after it go in this section, and its color inputs are listed under the same title on the Colors tab. A tab with 6 or more sections (or 30 or more inputs) gets a section list beside the inputs.

settings.section(id: const string, title: const string, { collapsed?: const bool = false, help?: const string = "", visible_if?: simple bool = true, enabled_if?: simple bool = true })
ParameterTypeDescription
idconst stringA stable id (letters, digits, _).
titleconst stringThe name shown in the settings, legend and data window.
collapsedconst booldefault falsetrue: closed until the user opens it.
helpconst stringdefault ""Help text shown under the heading.
visible_ifsimple booldefault trueThe visible if.
enabled_ifsimple booldefault trueThe enabled if.

Example

ChartScriptFragmentOpen in editor
settings.section("gen", "General")
const len = input.int(20, "Length")
settings.section("look", "Colors", { collapsed: true })
const lineColor = input.color(color.accent, "Line", { role: "accent" })

Since ChartScript 1

#settings.tabfunction

Starts an author tab of the settings dialog (your tabs replace Inputs and come before Colors, Style, Labels & text and Visibility; at most 8). The inputs after it go in this tab.

settings.tab(id: const string, title: const string, { icon?: const string = "", visible_if?: simple bool = true })
ParameterTypeDescription
idconst stringA stable id (letters, digits, _).
titleconst stringThe name shown in the settings, legend and data window.
iconconst stringdefault ""One of the icon.* constants.
visible_ifsimple booldefault trueThe visible if.

Example

ChartScriptFragmentOpen in editor
settings.tab("levels", "Levels", { icon: icon.layers })
const len = input.int(20, "Length")

Since ChartScript 1

#settings.validatefunction

A check across inputs, shown in the panel while the user types; "error" disables OK until it passes.

settings.validate(cond: simple bool, message: const string, { on?: const T = na, severity?: const string = "error" })
ParameterTypeDescription
condsimple boolThe condition that must hold (a settings condition).
messageconst stringThe message shown when it fails.
onconst Tdefault naThe inputs the message is shown under ([a, b]).
severityconst stringdefault "error"The severity.

Example

ChartScriptFragmentOpen in editor
const lo = input.int(20, "Low")
const hi = input.int(80, "High")
settings.validate(lo < hi, "Low must be below High", { on: [lo, hi] })

Since ChartScript 1

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