Sidechair

input.float()

Browse the reference

Adds a decimal-number setting to the script, optionally limited by minimum, maximum and step or chosen from a list.

Try it in the editor

input.float returns the decimal number the user chose in the settings, or defval until it is changed. Use it for multipliers, thresholds and percentages.

minval and maxval limit what can be entered and step sets the spinner increment, such as 0.1. With options, the setting becomes a dropdown of those exact values.

Syntax

Pine Script
input.float(defval: const int/float, title: const string (optional), minval: const int/float (optional), maxval: const int/float (optional), step: const int/float (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 float
input.float(defval: const int/float, title: const string (optional), options: tuple of const int/float 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 float

Arguments

NameTypeDefaultDescription
defvalconst int/floatrequiredValue the setting starts with. Any number, whole or fractional.
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
minvalconst int/floatnaSmallest value the setting accepts. A smaller entry is raised to this value.
maxvalconst int/floatnaLargest value the setting accepts. A larger entry is lowered to this value.
stepconst int/float1Increment 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/float values: [val1, val2, ...]naA list of allowed values, written [0.5, 1.0, 2.0]. When given, the setting is a dropdown.

Returns

input float: the chosen decimal number.

Remarks

  • On Sidechair: a saved value outside the limits is clamped to them, and one outside options falls back to defval.
  • On Sidechair: confirm, display and active are accepted and ignored.

Example

Pine ScriptBand multiplierOpen in editor
//@version=6
indicator("Adjustable bands", overlay = true)
mult = input.float(2.0, "Multiplier", minval = 0.1, maxval = 10, step = 0.1)
[mid, up, dn] = ta.bb(close, 20, mult)
plot(up, "Upper", color = color.red)
plot(dn, "Lower", color = color.green)
plot(mid, "Basis", color = color.gray)

See also

Runs on Sidechair