Pine Script input() Complete Guide: All Types With Examples

March 17, 2026

Pine Script input() Complete Guide: All Types With Examples

March 17, 2026

Pine Script's input() functions let you add configurable settings to your indicator or strategy that users can adjust through TradingView's indicator settings panel — without touching the code. This guide covers every input type in Pine Script v5 (input.int, input.float, input.string, input.bool, input.color, input.source, and input.timeframe) with all available parameters and a complete working example that uses them together.

⚙ Indicator Settings Length 14 Show Labels Source close ▾ Line Color
TradingView indicator settings panel with integer, boolean toggle, dropdown, and color inputs

1. input.int() — Integer Values

pine
//@version=5
indicator("Input Demo", overlay=true)

// input.int() — integer number input with validation
length = input.int(
    defval  = 14,           // default value shown in settings
    title   = "EMA Length", // label shown to the user
    minval  = 1,            // minimum allowed value
    maxval  = 500,          // maximum allowed value
    step    = 1,            // increment/decrement step
    tooltip = "Number of bars for the EMA calculation",
    group   = "EMA Settings"  // groups related inputs under a header
)

ema = ta.ema(close, length)
plot(ema, "EMA", color.blue)

2. input.float() — Decimal Values

// input.float() — same as input.int() but allows decimals
multiplier = input.float(
    defval  = 2.0,
    title   = "ATR Multiplier",
    minval  = 0.1,
    maxval  = 10.0,
    step    = 0.1    // increments by 0.1 with arrow keys
)

atrVal = ta.atr(14) * multiplier

3. input.string() — Text and Dropdowns

Pass an options array to turn a text input into a dropdown select:

// Dropdown: restrict to specific options
maType = input.string(
    defval  = "EMA",
    title   = "MA Type",
    options = ["EMA", "SMA", "RMA", "WMA"],
    tooltip = "Select the moving average calculation method"
)

// Use the selection in your logic
maValue = switch maType
    "EMA" => ta.ema(close, length)
    "SMA" => ta.sma(close, length)
    "RMA" => ta.rma(close, length)
    "WMA" => ta.wma(close, length)
    => ta.ema(close, length)  // default case

4. input.bool() — Toggle Switches

showLabels = input.bool(
    defval  = true,
    title   = "Show Labels",
    tooltip = "Toggle price labels on the chart"
)

showBands = input.bool(defval=false, title="Show Bands")

// Use in conditional logic
if showLabels
    label.new(bar_index, high, str.tostring(high, "#.##"), style=label.style_label_down)

5. input.color() — Color Pickers

// Color picker with transparency (0=opaque, 100=fully transparent)
bullColor = input.color(color.new(color.green, 0), title="Bullish Color")
bearColor = input.color(color.new(color.red, 20), title="Bearish Color")

barColor = close > open ? bullColor : bearColor
barcolor(barColor)

6. input.source() — OHLCV Selection

// Let user select which price to calculate on (close/open/high/low/hl2/hlc3)
src = input.source(close, title="Source")

// Now all calculations use the user-selected source
ema = ta.ema(src, length)
rsi = ta.rsi(src, 14)

7. input.timeframe() — Timeframe Picker

// Let user select a different timeframe for higher-timeframe analysis
htf = input.timeframe("D", title="Higher Timeframe")

// Request data from the selected timeframe
htfClose = request.security(syminfo.tickerid, htf, close)
htfEma   = request.security(syminfo.tickerid, htf, ta.ema(close, 50))

plot(htfEma, "HTF EMA", color.orange)

8. Organizing Inputs with group and inline

//@version=5
indicator("Organized Inputs", overlay=true)

// group= puts inputs under a collapsible section header
// inline= puts multiple inputs on the same row (use same string key)

fastLen  = input.int(9,  "Fast",   group="Moving Averages", inline="ma")
slowLen  = input.int(21, "Slow",   group="Moving Averages", inline="ma")
showMA   = input.bool(true, "Show", group="Moving Averages", inline="ma")

rsiLen   = input.int(14, "RSI Length", group="RSI", minval=1, maxval=50)
rsiOB    = input.int(70, "Overbought", group="RSI", inline="rsi_levels")
rsiOS    = input.int(30, "Oversold",   group="RSI", inline="rsi_levels")

For strategies that use these inputs to drive entries, see the pine script strategy.entry guide. For adding alerts based on your indicator's conditions, see the Pine Script alerts guide.

Summary

Use input.int() and input.float() for numeric settings with minval/maxval validation, input.string(options=[...]) for dropdowns, input.bool() for toggles, input.source() for OHLCV selection, and input.timeframe() for timeframe pickers. Organize related inputs with group="Name" and put side-by-side inputs on the same row with inline="key".