Skip to main content

Overview

input.* functions declare user-configurable parameters. Each call appears in the Inputs panel as a form control. You must call them at the top level of your script - never inside onBar.

Function reference

number
Integer spinner. opts: { min, max, step, group }.
number
Float spinner. Same opts as input.int.
boolean
Checkbox toggle.
string
Text field. Pass opts.options for a dropdown.
string
Color picker. Returns a hex color string.
(offset?) => number | null
OHLCV source selector. Returns a function you pass directly to ta.*. The default must be one of "open", "high", "low", "close", "hl2", "hlc3", "ohlc4".

Form control mapping

Grouping inputs

Use the group option to visually separate inputs in the panel:

The source function pattern

input.source returns an (offset?) => number | null function - the same shape as ctx.close, ctx.open, etc. Pass it directly to ta.*; do not call it yourself:
Calling input.* inside onBar throws a RuntimeError. Move all declarations to the top level.

Script lifecycle

Why top-level code runs once and onBar runs per bar.

Bar context

Built-in OHLCV accessors that share the source function shape.