input() family - Pine Script
input() family
Section titled “input() family”Overview
Section titled “Overview”Inputs let users customize script parameters without editing code. Pine Script offers a family of typed functions—input.int, input.float, input.bool, input.string, input.color, etc.—that return constant values you can read on every bar.
Syntax
Section titled “Syntax”input.int(defval, title, minval, maxval, step) → const intinput.float(defval, title, minval, maxval, step) → const floatinput.bool(defval, title) → const boolinput.string(defval, title, options) → const stringinput.color(defval, title) → const colorCommon arguments
Section titled “Common arguments”| Argument | Description |
|---|---|
defval | Default value shown on script load. |
title | Label displayed in the Inputs panel. |
minval / maxval | Optional numeric bounds for int/float inputs. |
step | Increment for numeric inputs. |
options | List of allowed values (for strings). |
Remarks
Section titled “Remarks”- Inputs return constants; assign them to variables once, then reuse throughout the script.
- Use descriptive titles—users see them in the settings dialog.
- For grouped inputs, pass
group/inlineparameters (Pine v5) to organize the UI.
Example
Section titled “Example”//@version=5indicator("Input demo", overlay=true)
emaLen = input.int(20, "EMA length", minval=1)showBand = input.bool(true, "Show band")bandPerc = input.float(1.5, "Band %", step=0.1)lineColor = input.color(color.teal, "Line color")
ma = ta.ema(close, emaLen)plot(ma, "EMA", color=lineColor)
if showBand upper = ma * (1 + bandPerc / 100) lower = ma * (1 - bandPerc / 100) plot(upper, "Upper", color=color.new(lineColor, 50)) plot(lower, "Lower", color=color.new(lineColor, 50))