Appearance
Inputs
Inputs become the script's settings form. Declare them at the top level; each call returns the value the user chose.
| Name | Description |
|---|---|
input.int() | A whole-number setting; the value is rounded. |
input.float() | A decimal-number setting. |
input.bool() | An on/off setting (a checkbox). |
input.select() | One of a fixed list of strings (a drop-down). |
input.string() | A free-text setting. |
input.source() | A price source chosen by the user (TradingView's input.source); returns the bar-aligned series. |
input.color() | A colour chosen by the user, as a CSS colour string (#rrggbb or rgba(...)). |
input.int()
ts
input.int(name: string, defaultValue: number, options?: NumberInputOptions): numberA whole-number setting; the value is rounded. name is its label and its key in saved settings.
Types: NumberInputOptions
input.float()
ts
input.float(name: string, defaultValue: number, options?: NumberInputOptions): numberA decimal-number setting.
Types: NumberInputOptions
input.bool()
ts
input.bool(name: string, defaultValue: boolean, options?: InputMeta): booleanAn on/off setting (a checkbox).
Types: InputMeta
input.select()
ts
input.select<T extends string>(name: string, defaultValue: T, options: readonly T[], meta?: InputMeta): TOne of a fixed list of strings (a drop-down).
Types: InputMeta
input.string()
ts
input.string(name: string, defaultValue: string, options?: InputMeta): stringA free-text setting.
Types: InputMeta
input.source()
ts
input.source(name: string, defaultValue?: Source, options?: InputMeta): SeriesA price source chosen by the user (TradingView's input.source); returns the bar-aligned series.
Types: Source, InputMeta, Series
input.color()
ts
input.color(name: string, defaultValue: string, options?: InputMeta): stringA colour chosen by the user, as a CSS colour string (#rrggbb or rgba(...)).
Types: InputMeta
Types
InputMeta
Shared by every input: a heading in the settings form, a hover hint, and a key that puts inputs on one row.
| Field | Type | Description |
|---|---|---|
group? | string | |
tooltip? | string | |
inline? | string |
NumberInputOptions
Bounds and step of a number input in the settings form.
NumberInputOptions extends InputMeta
| Field | Type | Description |
|---|---|---|
min? | number | |
max? | number | |
step? | number |
Source
A price source for input.source(): a candle field, an average of them, candle volume or the moving price.
ts
type Source = "open" | "high" | "low" | "close" | "hl2" | "hlc3" | "ohlc4" | "hlcc4" | "volume" | "movingPrice"