What the build checks

View as MarkdownOpen the editor

The declarations are read from the text without running it, and Run checks them before the compiler runs.

What it is

Declarations are literals: the extractor reads them from the text without running it, and each kind checks its own default's shape, a whole number for param.int, hex for param.color, one of the options for param.choice. Every kind takes one options object, every key optional, and a key the kind cannot use is refused by name. The Console shows each refusal on the declaration's line:

text
param.bool 'x' takes no min option (its value is not a number field)
A toggle declared with a min option: its line underlined in the editor, the declarations row in the Console with the refusal, the error count in the status bar, and Run blocked
  • Line 7 is underlined as you type: the extractor reads the declaration before anything compiles.
  • The Console row is tagged declarations and starts with the line number; the message names the kind, the setting and the option.
  • The status bar counts the error, and Run answers "Cannot run: 1 error(s) must be fixed first."

The refusal table

MistakeWhat the Console says
a key the kind does not takeparam.int options accept only { required, min, max, description, label, step, group, row, hint, when, hide, slider, unit, unit_default, confirm }, not 'tooltip'
a typed key on plain paramparam options accept only { required, min, max, description }, not 'label'
a number-field key on a toggleparam.bool 'x' takes no min option (its value is not a number field)
a unit picker on a rangeparam.range 'r' takes no unit option (a unit picker sits beside one number field, not a range)
hide without whenparam.int 'x' declares hide without when; hide names what happens when the when param is off, so declare when beside it
when naming a setting that is not a toggleparam.int 'x' when names 'y', which is not a param.bool (when takes the NAME of a param.bool, e.g. when: "show_bands")
a slider without both boundsparam.int 'x' declares slider without min and max (a slider needs both bounds)
a fractional param.int defaultparam.int 'x' default must be an integer literal, not 1.5
a choice default that is not an optionparam.choice 'm' default "c" is not one of its options (known: a, b)
a color that is not hexparam.color 'c' default takes "#rrggbb" or "#rrggbbaa", not 'red'
a range without boundsparam.range 'r' needs min and max (the two-handle slider's bounds), e.g. param.range("r", [1, 2], { min: 0, max: 100 })
a list without maxparam.list 'l' needs max (the most items the dialog may hold), e.g. param.list("l", [1,2], { max: 8 })
a list whose max alone crosses 128param.list 'l' max 200 would put 201 params on the sheet (max slots and the count); hosted lanes cap params at 128, so max is at most 127
a source default off the menuunknown field ohlcv.vwap for param.source 's' (known: open, high, low, close, hl2, hlc3, ohlc4, volume, hlcc4)
a reference to the wrong kindoutput 'h' color references "@k", which is not a param.color
a reference where no setting can paintdraw.line 'ln' color references "@c", but a param paints an output, a renderer or a legend entry only; write a colour literal here
a preset naming a compositepreset 'A' sets 'band', which is not a declared param on the sheet (a composite is set by its members, e.g. band_lo)
a preset value the setting cannot takepreset 'A' value for 'mode' takes one of its options as a string (fast, slow), not "Zed"
a name a composite already derivesparam 'band_lo' collides with the name param.range 'band' derives; rename one
more than 128 settingsthe sheet would carry 129 params after expansion (a range derives two, a list max + 1, a session three, a unit list one more); hosted lanes cap params at 128
a default above maxParam 'length' (default): default above max
min above maxParam 'length' (min): min must be <= max
a computed default (param("n", base * 2))param 'n' default must be a numeric literal (expected a numeric literal)
a string default on a number field (param("mode", "ema"))param 'mode' default must be a numeric literal (expected a numeric literal)
a name built from a variableparam names must be string literals (expected a string literal)

The rows by the page that explains them: the option rows on Options on a setting, the default rows on Setting kinds, the reference rows on The Style page, the preset rows on Presets, the source default and the cap on Picks, lanes, the cap.

Reserved names

A setting cannot take a name the chart keeps for itself: symbol, exchange, interval, transformations, ticksPerBar, currency, runMode, devViewerTier, errorMessage, splineVisibility, customScriptId, subType, scriptSource, catalogSource, wrunRef, wrunRegistryRef, wrunRunTarget, wrunAlertOutputs, wrunDraftRef, isProtectedScript, codeVisibility, hasGuide, scriptAuthor, or any name that starts with __style__ ("param 'symbol' uses a reserved name ...; rename it"). Every other name is free, smooth, width and opacity included.

Common errors

Each message with its symptom, its cause and its fix, beside the rest of the build's refusals: Common errors. The full grammar, every key and its legal values: Declarations and the sheet.