Adds a setting to the script and returns its value; the setting's type follows the type of the default.
input is the version-neutral form of the input.* functions. The type of defval decides the control: a whole number gives an int input, a decimal gives a float input, true or false gives a checkbox, text gives a string input, a color gives a color picker, and a price source such as close gives a source dropdown.
The call adds one row to the script's settings and returns the saved value, or defval when nothing is saved. The value is the same on every bar. Prefer the typed functions such as input.int, which also accept limits and options.
Syntax
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> input bool
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> input color
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> input int
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> input float
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> input string
input(defval: const int/float/bool/string/color or source-type built-ins, title: const string (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), display: const plot_display (optional), active: input bool (optional)) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const int/ | required | Default value. Its type picks the control: int, float, bool, string, color or a built-in price source. |
| title | const string | na | Name shown for the setting in the Inputs dialog. Give each setting its own name. |
| tooltip | const string | na | Text shown in a tooltip beside the input in the Settings dialog. |
| inline | const string | na | Entries sharing the same inline text sit on one row of the Settings dialog. |
| group | const string | na | Heading the input is listed under in the Settings dialog. |
| display | const plot_display | display. | Where the value appears: a display.* constant or a combination of them. |
| active | input bool | true | When false, the input is greyed out and cannot be edited. |
Returns
input bool or input color or input int or input float or input string or series float: the chosen value, with the type of defval.
Remarks
- Pine v4 arguments type, minval, maxval, step and options are also accepted here.
- On Sidechair: confirm, display and active are accepted and ignored.
Example
//@version=6
indicator("Plain inputs", overlay = true)
len = input(20, "Length")
src = input(close, "Source")
showAvg = input(true, "Show average")
plot(showAvg ? ta.sma(src, len) : na, "Average", color = color.orange)See also
Runs on Sidechair