Adds an integer setting to the script, optionally limited by minimum, maximum and step or chosen from a list.
input.int returns the whole number the user chose in the script's settings, or defval until it is changed. The value is fixed for the whole run, so it can drive a length argument such as ta.sma(close, len).
minval and maxval limit what can be typed, and step sets the spinner increment. Pass options instead to turn the control into a dropdown of fixed values; the limits do not apply then.
Syntax
input.int(defval: const int, title: const string (optional), minval: const int (optional), maxval: const int (optional), step: const int (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input int
input.int(defval: const int, title: const string (optional), options: tuple of const int values: [val1, val2, ...] (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input intArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const int | required | Default value, a whole number. |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| minval | const int | na | Smallest value the setting accepts. A smaller entry is raised to this value. |
| maxval | const int | na | Largest value the setting accepts. A larger entry is lowered to this value. |
| step | const int | 1 | Increment of the spinner buttons. |
| 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. |
| confirm | const bool | false | When true, the script asks for this value when it is first added to the chart. |
| 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. |
| options | tuple of const int values: [val1, val2, ...] | na | A list of allowed values, written [10, 20, 50]. When given, the setting is a dropdown. |
Returns
input int: the chosen integer.
Remarks
- On Sidechair: a saved value is rounded to a whole number and clamped to minval and maxval; a value outside options falls back to defval. Saved values are keyed by title, so renaming the title resets the setting.
- On Sidechair: the options list may also be passed as the third positional argument, as
input.int(10, "Length", [5, 10, 20]). - On Sidechair: confirm, display and active are accepted and ignored.
Example
//@version=6
indicator("Adjustable average", overlay = true)
len = input.int(14, "Length", minval = 2, maxval = 200, step = 2, tooltip = "Bars in the average")
mode = input.int(1, "Line width", options = [1, 2, 3])
plot(ta.ema(close, len), "EMA", color = color.blue, linewidth = mode)See also
Runs on Sidechair