Settings the user can change
An input call declares one control in the indicator settings and returns its current value on every bar. The call must be the direct initialiser of a top level declaration and every argument must be a literal; a negative number such as -300 counts as a literal. Use let rather than var for inputs.
| Signature | Returns |
|---|---|
| input.int(default: int, key: string, title: string [, min: int, max: int, step: int]) -> int | Whole number control |
| input.float(default: float, key: string, title: string [, min: float, max: float, step: float]) -> float | Decimal control |
| input.bool(default: bool, key: string, title: string) -> bool | Checkbox |
| input.color(default: color, key: string, title: string) -> color | Colour picker with an opacity slider. The saved value is "#RRGGBB" at full opacity and "#RRGGBBAA" below it. |
- key must match [A-Za-z][A-Za-z0-9_]{0,63} and must be unique inside the script. It is what the saved setting is stored under, so renaming it resets the control.
- title holds 1 to 80 characters and is what the user reads.
- Defaults and bounds must be finite, min must not exceed max, and a step must be positive. For input.int the default, bounds and step must all be whole numbers.
- A saved value outside the declared bounds is clamped before the script sees it.
- An input inside an if branch, a function, or an arithmetic expression is rejected.
- input.color accepts "#RRGGBB" or "#RRGGBBAA". The last pair is the opacity, 00 fully transparent to FF fully opaque, and a six digit default means fully opaque.
- Where a drawing call also takes its own opacity argument, such as plot.zone, plot.box, plot.candle_color, plot.panel_area and profile.fold, the two multiply: a "#RRGGBB80" fill at opacity 0.5 draws at roughly a quarter.
let length: int = input.int(20, "length", "Length", 2, 400, 1)
let threshold: float = input.float(10, "deltaPercent", "Delta percent", 0, 100, 0.5)
let show_text: bool = input.bool(true, "showText", "Show text")
let up_color: color = input.color("#22C55E", "upColor", "Up")
let zone_fill: color = input.color("#22C55E40", "zoneFill", "Zone fill")