Skip to content

input() family - Pine Script

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.

input.int(defval, title, minval, maxval, step) → const int
input.float(defval, title, minval, maxval, step) → const float
input.bool(defval, title) → const bool
input.string(defval, title, options) → const string
input.color(defval, title) → const color
ArgumentDescription
defvalDefault value shown on script load.
titleLabel displayed in the Inputs panel.
minval / maxvalOptional numeric bounds for int/float inputs.
stepIncrement for numeric inputs.
optionsList of allowed values (for strings).
  • 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/inline parameters (Pine v5) to organize the UI.
//@version=5
indicator("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))