feature
Settings inputs and dialog
Traders change length, color, and other options in a settings dialog — you declare those controls with input.*, dialog, and layout, then read them as ctx.params in your script.
Use this when you want a parameter the user can tweak without editing code. Indicators get the full settings surface; definitions support the common subset.
Who uses what
API | Indicator | Definition |
|---|---|---|
| yes | yes |
| yes | yes |
| yes | — |
| yes | yes |
| yes | — |
Inputs → ctx.params
Every input needs an id. Inside onBar, read ctx.params.<id>.
dialog({ title: "EMA" });
const length = input.number({ id: "length", label: "Length", default: 20, min: 1 });
const color = input.color({ id: "color", label: "Color", default: "#2196f3" });
const htf = input.timeframe({ id: "htf", label: "Higher TF", default: "60" });
layout(
tab({ id: "main", title: "Main" },
section({ id: "params", title: "Parameters" }, length, color, htf))
);
function onBar(ctx) {
const len = ctx.params.length;
const tf = ctx.params.htf;
}when — conditional visibility
const mode = input.select({
id: "mode",
label: "Mode",
default: "simple",
options: [
{ value: "simple", label: "Simple" },
{ value: "advanced", label: "Advanced" },
],
});
// Wire with when(mode).equals("advanced") in layoutTimeframe inputs
Timeframe arguments to ctx.security / ctx.tf must be literals or values from input.timeframe (ctx.params.<id>). Never concatenate timeframe strings.
Definition note
Definitions may also use legacy meta.params (FlowParamDef). Prefer input.* for new scripts.
Indicator-only extras
input.array + output.bandTemplate, style inputs (lineStyle / lineWidth), and pane() routing live under Series types and Overlay vs pane.
