Skip to main content
Settings the user changes in the settings panel. Declared at the top level only. Changing an input re-runs the script from its first bar.

input

(label: string, defaultValue: number, options?: NumberInputOptions): number
(label: string, defaultValue: number, options?: NumberInputOptions): number
(label: string, defaultValue: boolean, options?: InputOptions): boolean
(label: string, defaultValue: string, options?: InputOptions): string
<T extends string>(label: string, defaultValue: T, choices: readonly T[], options?: InputOptions & { labels?: Partial<Record<T, string>> }): T
One of a fixed list of strings. labels names values for the settings panel and the legend, such as { lastHour: 'Last hour' }, so the values can stay stable while the words change.
(label: string, defaultValue: SourceName, options?: InputOptions): SourceName
Which bar value to read, such as close or hl2. Read it with bars().source(name).
(label: string, defaultValue: Color | null, options?: InputOptions): Color | null
A colour; null follows the theme.
(label: string, defaultValue: Time | null, options?: InputOptions): Time | null
A moment the user picks by clicking the chart, such as an anchored VWAP’s start. null until picked.
(label: string, defaultValue: IntervalCode | 'chart', options?: InputOptions): IntervalCode
An interval code. 'chart' stands for the chart’s own interval, as a default and as the user’s choice: the script then reads the chart’s code ('15m' on a 15-minute chart), and a bars({ interval }) stream with it is the chart’s own stream.
(label: string, defaultValue: string | null, options?: InputOptions): string | null
A market symbol such as BTC or xyz:GOLD; null means the chart’s market.
(label: string, defaultValue: readonly string[], options?: InputOptions): readonly string[]
A list of wallet addresses, lower-case hex.
(label: string, defaultValue: readonly string[], options?: InputOptions): readonly string[]
A list of market symbols, such as a basket for ml.pca: at most 50, trimmed, without repeats. Open one stream per market with markets.map((m) => bars({ market: m })).
(label: string, defaultValue: number | null, options?: InputOptions & { drag?: boolean }): number | null
An algo’s price: a number field, and with drag: true a line on the chart the trader drags, as the ticket’s TP/SL. A null default is an empty field, for an optional price; it reads null until set.
(label: string, defaultValue: OrderSize, options?: InputOptions): OrderSize
An algo’s size: an amount and its unit ($, coins, % of the position, % of equity), as the ticket’s size.
(label: string, defaultValue: Side, options?: InputOptions): Side
Buy or sell.
(label: string, defaultValue: number, options?: NumberInputOptions): number
A percent, such as a price band.
(label: string, defaultValue: Duration, options?: InputOptions): number
A length of time written as the trader writes it ('30s', '5m', '4h', '2d'), read in seconds.

InputOptions

string
string
boolean
Show the input on the same row as the previous one.
boolean
false keeps the input’s value out of the script’s name in the legend, which otherwise carries its numbers, sources, choices and intervals (“RSI 14 close”). For a setting that says where something draws rather than what it computes, such as a table’s corner.

NumberInputOptions

number
number
number
'usd' | 'bps'
For int and float: what the number counts, written in its field ('usd' dollars, 'bps' basis points).

Next step

Continue with Streams.
Last modified on November 15, 2026