Adds a decimal-number setting to the script, optionally limited by minimum, maximum and step or chosen from a list.
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
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 floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const int/ | required | Value the setting starts with. Any number, whole or fractional. |
| 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/ | na | A 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
//@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