Skip to main content
An input is a setting the person using your script can change from the chart without editing the code. You call an input function once; the platform shows a control for it, and the call returns the value chosen. The value is fixed for a run of the script, so it can be used where an input value is required, such as hline(price) and plot(linewidth=...). input(defval, ...) picks the kind from the type of defval (bool, color, int, float, string, or a series for a source).

Common arguments

After defval, every input takes title, tooltip (help text), inline (inputs with the same string share one row), group (inputs with the same string sit under one heading), confirm and display. All are const. defval is const too, except for input.source, and it may not be na:
The compiler says: Argument defval of input.int() cannot be na.
step may be named: input.int(14, "Length", step=5) works. The compiler does not check that defval lies between minval and maxval. input.int takes only an int default (5.5 is refused); input.float accepts 5. display takes display.* constants, combined with +, and only tells the platform where to show the value; the script never sees it. Its default is display.none for input.bool, input.color, input.text_area and input.time, and display.all for every other input (int, float, string, source, price, session, timeframe, enum).

Options

options=[...] turns a number or string input into a list. The default must be one of the options:
The compiler says: Argument defval of input.int() value 10 is not in options [7, 14, 21].

Time

input.time takes milliseconds since 1970 (UTC). A default written as timestamp("2024-01-01") passes the editor’s check and fails when the script is added to the chart, because timestamp is evaluated only when the script runs and is na until then:
The compiler says (when added to the chart): Argument defval of input.time() cannot be na. Give the number instead, or build the date from three integer inputs, which are evaluated when the script runs:

Enum

input.enum(defval, title, options, ...) takes a member of an enum you declared (see Custom types and enums); the member’s title is the text of the control. options lists the members offered and must contain defval.

input.source accepts names, not expressions

The default of input.source must be one of the eight price series above: input.source(talib.sma(close, 3)) is refused as not a valid source variable.