Charts
Concepts

Inputs

Declare the settings of a script. Values are saved per chart.

inputs declares the script's settings. The settings dialog is generated from them, values are saved per chart, and ctx.inputs holds the current values.

inputs: {
  length: input.int({ default: 20, min: 1, max: 500, label: "Length" }),
  source: input.select({ default: "Close", options: ["Open", "High", "Low", "Close"] }),
  line: input.lineStyle({ default: { color: "#f59e0b", width: 2 }, label: "Line", group: "Style" }),
},

ctx.inputs.length is a number, ctx.inputs.source is "Open" | "High" | "Low" | "Close", ctx.inputs.line passes to g.line as is.

Builders

BuilderValueOptions
input.int, input.floatnumbermin, max, step
input.boolboolean
input.stringstring
input.colorCSS color
input.selectunion of optionsoptions
input.pricepricenumber field
input.timeepoch msdate and time field
input.symbolsymbol code, e.g. "NQ"
input.timeframeTimeframe, e.g. "5m"
input.lineStyleLineStylesolid, dashed, dotted

All take label (the key when omitted), group (inputs with the same group share a section) and tooltip.

Changes restart

Changing an input restarts the script: state is dropped and history replays. So inputs can shape subscribe, e.g. trades({ minSize: ctx.inputs.minSize }).

An invalid saved value, e.g. out of min/max, falls back to its default and shows as an error.

On this page