input.* Parameter Reference
Complete reference for all input.* functions in ATK PyneScript V6 — choosing the right input family, parameters, and merging patterns.
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 | Return type | Typical args | Use case |
|---|---|---|---|
input.int(defval=0, title="", key=None, **kwargs) | int | minval, maxval, step | Lengths, lookbacks, counts. |
input.float(defval=0.0, ...) | float | minval, maxval, step | Multipliers, thresholds, sizing. |
input.bool(defval=False, ...) | bool | Boolean toggles | Feature flags and display controls. |
input.string(defval="", ...) | str | Plain text | Modes, source keys, labels. |
input.text_area(defval="", ...) | str | Long-form text | Notes or text payload input. |
input.time(defval=0, ...) | int | Timestamp default | Time anchors. |
input.price(defval=0.0, ...) | float | Price level default | Fixed price references. |
input.source(defval="close", ...) | str | Source field name | Select market source column. |
input.symbol(defval="", ...) | str | Symbol selector | External symbol input. |
input.session(defval="", ...) | str | Session string | Session filtering. |
input.timeframe(defval="", ...) | str | Timeframe string like 15m | MTF confirmation. |
input.color(defval="#00c853", ...) | str | Hex or color string | Visual style input. |
input.enum(defval=None, title="", key=None, options=None, **kwargs) | Any | options | Bounded choice selection. |
How defval works — defval 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 matters — key 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 family | Choose it when... | Practical guidance |
|---|---|---|
input.int | The value is a discrete count, lookback, or bar distance. | Use for lengths and counts. Add minval=1 when zero or negative values would make the indicator invalid. |
input.float | The value is continuous: multipliers, thresholds, percent-like knobs. | Use step to control UI granularity. A BBands multiplier is a float because 1.5 and 2.25 are meaningful values. |
input.bool | The setting toggles a feature on or off. | Good for showing markers, enabling a filter, or switching between base and advanced output layers. |
input.string | The user chooses a small freeform mode label or source name. | Use it when values are text but not naturally bounded by a strict enum. For highly constrained choices, prefer input.enum. |
input.source | The user should select a column-like market source. | Use for open, high, low, close, or derived source names. Always implement a fallback when the chosen source is absent. |
input.timeframe | The user selects an alternate timeframe for confirmation or aggregation. | Use only when the script actually calls request.security or similar logic. Do not add a timeframe input as decoration. |
input.price | The setting is a fixed chart level. | Use for thresholds, zones, and manual anchors where the number represents a price, not a generic multiplier. |
input.time | The user must choose a specific timestamp. | Useful for fixed-range studies, manual windows, and time-anchored objects. |
input.color | The user controls styling without changing logic. | Keep color inputs cosmetic. Do not overload them with semantic decisions that should be real boolean or enum settings. |
input.enum | The choice must be limited to known valid values. | Best for modes like sma versus ema, panel position choices, or named logic variants where arbitrary text would be error-prone. |
Code Example: Choosing the Right Input Family#
from source import input
# Discrete bar count.
length = input.int(20, title="Length", key="length", minval=1)
# Continuous multiplier.
multiplier = input.float(2.0, title="StdDev Mult", key="multiplier", minval=0.1, step=0.1)
# Free text for lightweight labels.
label_text = input.string("baseline", title="Label", key="label_text")
# Multi-line notes.
notes = input.text_area("alpha\nbeta", title="Notes", key="notes")
# Interactive chart-pick pair.
trigger_time = input.time(1700000000, title="Trigger Time", key="trigger_time", confirm=True)
trigger_price = input.price(101.25, title="Trigger Price", key="trigger_price", confirm=True)
# Market source selector.
source_type = input.source("close", title="Source", key="source_type")
# Symbol and session selectors.
ticker = input.symbol("BINANCE:BTCUSDT", title="Ticker", key="ticker")
session_value = input.session("0930-1600", title="Session", key="session_value")
# Only add timeframe when you really call request.security later.
confirm_tf = input.timeframe("15m", title="Confirm TF", key="confirm_tf")
# Input-owned color value.
line_color = input.color("#2962ff", title="Line Color", key="line_color")
# Bounded named choice.
ma_mode = input.enum("ema", title="MA Mode", key="ma_mode", options=["sma", "ema", "rma"])Rule of thumb: if free text would let the user enter invalid values, do not use input.string. Use input.enum or a more specific input family instead.
Interactive inputs: ATK now preserves confirm, time/price pairings, and picked-value metadata for input.time and input.price. Use those fields when the user should anchor a chart event explicitly rather than typing a generic number.
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"]
# use p["length"] and p["multiplier"] for computation