Sidechair

input.int()

Browse the reference

Adds an integer setting to the script, optionally limited by minimum, maximum and step or chosen from a list.

Try it in the editor

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

Pine Script
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 int

Arguments

NameTypeDefaultDescription
defvalconst intrequiredDefault value, a whole number.
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
minvalconst intnaSmallest value the setting accepts. A smaller entry is raised to this value.
maxvalconst intnaLargest value the setting accepts. A larger entry is lowered to this value.
stepconst int1Increment of the spinner buttons.
tooltipconst stringnaText shown in a tooltip beside the input in the Settings dialog.
inlineconst stringnaEntries sharing the same inline text sit on one row of the Settings dialog.
groupconst stringnaHeading the input is listed under in the Settings dialog.
confirmconst boolfalseWhen true, the script asks for this value when it is first added to the chart.
displayconst plot_displaydisplay.allWhere the value appears: a display.* constant or a combination of them.
activeinput booltrueWhen false, the input is greyed out and cannot be edited.
optionstuple of const int values: [val1, val2, ...]naA 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

Pine ScriptLength input with limitsOpen in editor
//@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