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, visible_by }, 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 cannot open a row | param.int 'x' when names 'y', which is a param.color (when names a param.bool, param.choice, param.int, param.number or param.multi: "name", "!name", "name=v", "name!=v" or "name in a,b", e.g. when: "show_bands") |
when comparing a choice with a value it does not hold | param.int 'x' when compares the choice 'y' with 2; a choice holds its option index, 0 to 1 (a, b) |
when spelling no gate | param.int 'x' when 'y == 1' names no setting: when takes "name", "!name", "name=v", "name!=v" or "name in a,b", naming the setting that opens the row (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, not 'base * 2'; write the number, e.g. param("n", 14) |
a string default on a number field (param("mode", "ema")) | param 'mode' default must be a numeric literal, not '"ema"'; write the number, e.g. param("mode", 14) |
| 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.
Warnings
Three findings warn on the declaration's line and never block Run: each names a setting that sits in the dialog and does nothing.
| Finding | What the Console says |
|---|---|
| a setting no code reads | param 'x' is never read, so changing the setting changes nothing: read it with p_x() where the code needs it, or remove the declaration (in a file with onBar(), the form in Common errors) |
a setting read only inside branches another setting decides, with no when naming it | param 'x' is read only inside branches 'mode' decides (line 12), so its row changes nothing while 'mode' closes them: give it a when naming 'mode' ... |
| a paint target on an output key its plot does not draw | param 'dash' paints hist. |
A branch decides a read when the read sits in an if arm, a ? : arm,
the right side of an && or ||, or the rest of a block after an if
that returns, and the test reads the other setting against constants. A
setting read on both sides of one test (an if and its else, a chart
path and a higher timeframe path) needs no when, and neither does a row
whose section's toggle or when already names the setting. A bar or
histogram column takes no line style or smooth target, and neither does a
shape, scatter or candle. A column's width paints: it is a share of the
bar slot, so a Width setting bound there resizes the columns.
An official OpenMarket indicator cannot be published with any of the three, so every setting it ships is live.
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.