What the build checks
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:
param.bool 'x' takes no min option (its value is not a number field)
- Line 7 is underlined as you type: the extractor reads the declaration before anything compiles.
- The Console row is tagged
declarationsand 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
| Mistake | What the Console says |
|---|---|
| a key the kind does not take | param.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 param | param options accept only { required, min, max, description }, not 'label' |
| a number-field key on a toggle | param.bool 'x' takes no min option (its value is not a number field) |
| a unit picker on a range | param.range 'r' takes no unit option (a unit picker sits beside one number field, not a range) |
hide without when | param.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 toggle | param.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 bounds | param.int 'x' declares slider without min and max (a slider needs both bounds) |
a fractional param.int default | param.int 'x' default must be an integer literal, not 1.5 |
| a choice default that is not an option | param.choice 'm' default "c" is not one of its options (known: a, b) |
| a color that is not hex | param.color 'c' default takes "#rrggbb" or "#rrggbbaa", not 'red' |
| a range without bounds | param.range 'r' needs min and max (the two-handle slider's bounds), e.g. param. |
a list without max | param.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 128 | param.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 menu | unknown field ohlcv.vwap for param.source 's' (known: open, high, low, close, hl2, hlc3, ohlc4, volume, hlcc4) |
| a reference to the wrong kind | output 'h' color references "@k", which is not a param.color |
| a reference where no setting can paint | draw.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 composite | preset '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 take | preset 'A' value for 'mode' takes one of its options as a string (fast, slow), not "Zed" |
| a name a composite already derives | param 'band_lo' collides with the name param.range 'band' derives; rename one |
| more than 128 settings | the 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 max | Param 'length' (default): default above max |
min above max | Param '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 variable | param 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.