The basic form
length = input.int(20, "Length", minval=1)
source = input.source(close, "Source")
ma = ta.sma(source, length)
plot(ma)
- Every
input.*()call registers a row in the Inputs tab and returns the current value. - The first argument is the default; the second is the title shown in the dialog.
- Omitting the title defaults to an auto-generated id (
in_0,in_1, …). Always provide a title.
Typed input functions
input.int(defval, title, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?, active?)
Integer slider / stepper. options=[a, b, c] turns it into a dropdown of fixed values.
len = input.int(14, "Length", minval=1, maxval=200)
mult = input.int(2, "Multiplier", options=[1, 2, 3, 4, 5])
input.float(defval, title, minval?, maxval?, step?, tooltip?, inline?, group?, confirm?, display?, options?, active?)
Floating-point input.
threshold = input.float(0.5, "Threshold", minval=0.01, step=0.05)
input.bool(defval, title, …, active?)
Checkbox. Pair active= with another input.bool or input.int to gate the control (greyed-out unless the condition holds).
useFilter = input.bool(true, "Use filter")
strict = input.bool(false, "Strict mode", active=useFilter)
input.string(defval, title, options?, …)
Text or dropdown:
mode = input.string("Fast", "Mode", options=["Fast", "Slow", "Custom"])
input.color(defval, title, …)
Swatch with a colour picker:
bull = input.color(color.lime, "Bull colour")
bear = input.color(color.red, "Bear colour")
input.source(defval, title, …)
Picks a bar series — close, open, hl2, hlc3, ohlc4, or another indicator's output.
src = input.source(close, "Source")
input.symbol(defval, title, …)
Opens a symbol search dialog.
symA = input.symbol("NSE:NIFTY", "Benchmark")
The return is a string like "NSE:TCS" or a canonical secmaster key such as "NSEE11536:TCS".
input.timeframe(defval, title, …)
Picks a timeframe ("5", "60", "D", …):
htf = input.timeframe("D", "Higher timeframe")
input.session(defval, title, …)
Session string ("0915-1530" or "0915-1530:12345"):
sess = input.session("0915-1530", "Trading session")
input.time(defval, title, …)
Date-time picker. Default is an epoch ms (use timestamp(…)):
startT = input.time(timestamp("2020-01-01 00:00"), "Start")
input.price(defval, title, …)
Price picker that lets the user click on the chart to set a value:
level = input.price(100.0, "Level")
input.textarea(defval, title, …)
Multiline string:
notes = input.textarea("", "Notes")
input.enum(defval, title, …)
Dropdown driven by a user-defined enum:
enum Trend
up = "Bullish"
down = "Bearish"
flat = "Neutral"
t = input.enum(Trend.up, "Trend mode")
input(defval, title, …) — type-inferred
The generic form infers its type from defval. Prefer the typed form; this exists so legacy scripts compile unchanged.
length = input(20, "Length") // int
src = input(close, "Source") // source
colour = input(color.lime, "Colour") // color
Grouping and inline layout
group=
Collect related inputs under a section header. The dialog renders one <h4> per unique group name (in first-appearance order; repeated groups fold into their first section):
group_zone = "Zone Marking"
group_ma = "MA Settings"
showDemand = input.bool(true, "Demand", group=group_zone)
showSupply = input.bool(true, "Supply", group=group_zone)
maLen = input.int (20, "Length", group=group_ma, minval=1)
inline=
Inputs sharing an inline= string and the same group= render on one horizontal row. Common pattern: a boolean toggle plus a colour swatch.
showMa1 = input.bool(true, "Show MA", group="MA Settings", inline="ma1")
colMa1Up = input.color(color.lime, "", group="MA Settings", inline="ma1")
colMa1Dn = input.color(color.red, "", group="MA Settings", inline="ma1")
The dialog caps labelled members per inline row at two to prevent long labels from colliding; label-less members (the swatches) ride along without counting.
tooltip=
Adds a hover help icon next to the control:
length = input.int(14, "Length", tooltip="Lookback window. Lower = more sensitive.")
active=
Grey out a control when another input is in a given state:
useFilter = input.bool(true, "Use filter")
strict = input.bool(false, "Strict mode", active=useFilter) // only if useFilter == true
negatedEx = input.bool(false, "Fallback", active=not useFilter) // only if useFilter == false
The reference supports active = someBoolVar or active = not someBoolVar.
confirm=
Mark an input so the dialog opens automatically the first time the script is added, so the user can override important defaults:
level = input.price(100.0, "Trigger level", confirm=true)
display=
Where the input's current value appears outside the Settings dialog:
length = input.int(20, "Length", display=display.data_window + display.status_line)
Inputs vs constants
- A
const(var int LEN = 20) is baked into the script. - An
inputbecomes part of the script's wire contract — a version with different inputs renders a different dialog.
Reading inputs inside strategies
Inputs feed strategy sizing and risk literally the same way they feed indicators:
riskPct = input.float(1.0, "Risk per trade (%)")
strategy.entry("Long", strategy.long,
qty = strategy.equity * riskPct / 100 / close)
See also
- Alerts — placeholders in alert messages
- Script structure
- Enums