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

dialog

yes

yes

input.number / boolean / text / select / color / timeframe

yes

yes

input.multiSelect / lineStyle / lineWidth / range / array

yes

layout / tab / section / group / when

yes

yes

pane(...)

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 layout

Timeframe 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.

Next

  1. Drawing on the chart

  2. Multi-timeframe and runOn