Skip to content

Inputs (input)

Input functions declare user-configurable parameters. They appear as controls in the indicator settings panel.

input.int(key, defaultValue, label, opts?)

Integer input with optional min/max/step.

  • key string — unique identifier
  • defaultValue number — initial value
  • label string — display label
  • opts { min?: number, max?: number, step?: number } — constraints (step defaults to 1)

Returns number.

ts
const len = input.int('length', 20, 'Length', { min: 2, max: 500 })

input.float(key, defaultValue, label, opts?)

Floating-point input with optional min/max/step.

Same parameters as input.int, but step defaults to 0.1.

ts
const mult = input.float('mult', 2.0, 'StdDev Multiplier', { min: 0.1, max: 5 })

input.bool(key, defaultValue, label)

Boolean toggle.

ts
const showFill = input.bool('fill', true, 'Show Fill')

input.string(key, defaultValue, label)

Free-text string input.

ts
const suffix = input.string('suffix', '', 'Label Suffix')

input.select(key, defaultValue, label, options)

Dropdown selector. The user sees a <select> populated from options.

  • defaultValue — one of the option values
  • optionsArray<T | { label: string, value: T }>. Plain values use the value as both label and key; { label, value } lets you display a friendly label for each option.
ts
// Plain values
const tf = input.select('tf', '5m', 'Timeframe', ['1m', '5m', '15m', '1H', '4H', 'D'])

// With friendly labels
const mode = input.select('mode', 'wick', 'Zone Type', [
  { label: 'Wick (rejection)', value: 'wick' },
  { label: 'Full Candle',      value: 'full' },
])

input.source(key, defaultValue, label)

Price source picker. Returns a Series. The user sees a dropdown with Close, Open, High, Low.

  • defaultValue — one of 'close', 'open', 'high', 'low'
ts
const src = input.source('source', 'close', 'Source')
const sma = ta.sma(src, 20) // works with whichever source the user picks

input.color(key, defaultValue, label)

Color picker. The settings dialog shows a hex swatch plus an alpha slider; the value passed to your script is an rgb(r, g, b) or rgba(r, g, b, a) string. You can pass either form as the default, and #RRGGBB / #RRGGBBAA are also accepted.

ts
// Solid color
const lineColor = input.color('color', '#2962ff', 'Line Color')
plot(ta.sma(close, 20), 'SMA', lineColor)

// Translucent fill
const zone = input.color('zone', 'rgba(38, 166, 154, 0.30)', 'Demand Zone')
box(+time[5], +time, +high, +low, zone)

Tradify Charts Scripting Documentation