Skip to main content
ATK Pine Script®

input.* Namespace

All input registration functions — int, float, bool, string, source, timeframe, color, enum, and more — with guidance on when to use each.

input.* Namespace#

Every input registration appends metadata into the script context and returns the default value immediately, so your module can use it as a plain Python value.

Method reference#

MethodReturn typeTypical argsUse case
input.int(defval=0, title="", key=None, **kwargs)intminval, maxval, stepLengths, lookbacks, counts.
input.float(defval=0.0, ...)floatminval, maxval, stepMultipliers, thresholds, sizing.
input.bool(defval=False, ...)boolFeature flags and display controls.
input.string(defval="", ...)strPlain textModes, source keys, labels.
input.text_area(defval="", ...)strLong-form textNotes or text payload input.
input.time(defval=0, ...)intTimestamp defaultTime anchors.
input.price(defval=0.0, ...)floatPrice level defaultFixed price references.
input.source(defval="close", ...)strSource field nameSelect market source column.
input.symbol(defval="", ...)strSymbol selectorExternal symbol input.
input.session(defval="", ...)strSession stringSession filtering.
input.timeframe(defval="", ...)strTimeframe string like 15mMTF confirmation.
input.color(defval="#00c853", ...)strHex or color stringVisual style input.
input.enum(defval=None, title="", key=None, options=None, **kwargs)AnyoptionsBounded choice selection.

Key concepts#

How defval worksdefval is the value returned immediately at import time and the value used when the runtime has not supplied an override. Treat it as the script's safe startup configuration.

Why key matterskey is the stable identity for the setting in the runtime. Keep it short, explicit, and durable. Changing keys later breaks continuity between saved settings and the script contract.

How to merge params — Use inputs as typed defaults, then merge params over them inside the frame builder. That keeps the script runnable as plain Python while still respecting runtime overrides.

Choosing the right input family#

Input familyChoose it when...Practical guidance
input.intThe value is a discrete count, lookback, or bar distance.Add minval=1 when zero or negative values would make the indicator invalid.
input.floatThe value is continuous: multipliers, thresholds, percent-like knobs.Use step to control UI granularity.
input.boolThe setting toggles a feature on or off.Good for showing markers, enabling a filter, or switching output layers.
input.stringThe user chooses a small freeform mode label or source name.For highly constrained choices, prefer input.enum.
input.sourceThe user should select a column-like market source.Always implement a fallback when the chosen source is absent.
input.timeframeThe user selects an alternate timeframe for confirmation.Use only when the script actually calls request.security. Do not add as decoration.
input.priceThe setting is a fixed chart level.Use for thresholds, zones, and manual anchors.
input.timeThe user must choose a specific timestamp.Useful for fixed-range studies and time-anchored objects.
input.colorThe user controls styling without changing logic.Keep color inputs cosmetic. Do not overload with semantic decisions.
input.enumThe choice must be limited to known valid values.Best for modes like sma vs ema, or named logic variants.

Input merging pattern#

length = input.int(20, title="Length", key="length", minval=1)
multiplier = input.float(2.0, title="StdDev Mult", key="multiplier", minval=0.1, step=0.1)
source_type = input.source("close", title="Source", key="source_type")


def build_indicator_frame(df, params=None):
    frame = df.copy().reset_index(drop=True)
    p = {
        "length": int(length),
        "multiplier": float(multiplier),
        "source_type": str(source_type),
    } | dict(params or {})
    source_name = str(p.get("source_type", "close") or "close")
    source_series = frame[source_name] if source_name in frame.columns else frame["close"]
    ...

Mixed input families example#

# input.int for discrete lookbacks
length = input.int(20, title="Length", key="length", minval=1)

# input.float for continuous knobs such as multipliers
multiplier = input.float(2.0, title="StdDev Mult", key="multiplier", minval=0.1, step=0.1)

# input.source when the user chooses a market source column
source_type = input.source("close", title="Source", key="source_type")

# input.timeframe only when the script really does MTF work
confirm_tf = input.timeframe("15m", title="Confirm TF", key="confirm_tf")

# input.color for cosmetic styling, not logic decisions
line_color = input.color("#00c853", title="Line Color", key="line_color")

# input.enum for bounded named choices
ma_mode = input.enum("ema", title="MA Mode", key="ma_mode", options=["sma", "ema", "rma"])