Inputs
14 entries. What each one takes, what it returns, and a working example.
input(default, min?, max?, step?, name?, group?, tooltip?, inline?, options?)
Optimizable parameter. Optimizer scans min→max by step. min/max/step/name can be given positionally in that order OR by keyword — input(20, min=10, max=50, step=5, name="length") — avoids ambiguity. If options=[...] is given (instead of min/max/step), a fixed-value dropdown — for text AND numeric inputs (mutually exclusive with min/max/step, like referans dil). Settings-panel layout (all given by name only): a constant-string group shows the input under a titled section with that name in the settings panel (inputs sharing a group are grouped together); a constant-string tooltip shows a help icon next to the input (revealed on hover); a constant-string inline shows inputs that share the same inline value SIDE BY SIDE (on one row) in the panel.
An optimizable parameter value.
Note
Optimization sweeps from min to max with step; if min/max are not given, it behaves like a fixed value. min/max/step/name can be given positionally in that order OR by keyword — input(20, min=10, max=50, step=5, name="length") is the recommended, unambiguous form. If options=[...] (a list of fixed values) is passed, a dropdown is shown instead of min/max/step — this also applies to numeric inputs (numeric options and min/max/step are mutually exclusive). Settings-panel layout: group/tooltip/inline are all given by name only constant strings (see arguments).
Optimization sweeps from min to max with step; if min/max are not given, it behaves like a fixed value.
len = input(20, min=10, max=50, step=5, name="length") plot(sma(close, len))
Adds a length box to the settings panel ranging from 10 to 50 in steps of five and plots an average with it; the line updates as soon as the user changes the value.
inputBool(default, title?, group?, tooltip?, inline?)
Boolean input. Settings other than the title are passed BY NAME (min = 1, group = "Settings"); for numeric inputs min/max/step may also be given positionally. Result: True
The checkbox state (the default if none is chosen).
Note
Defines an on/off checkbox; to toggle showing/hiding a feature. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
show = inputBool(true, "Show average") plot(iff(show, sma(close, 20), na))
Defines a checkbox; when ticked the average is plotted, otherwise it is left empty.
inputColor(default, title?, group?, tooltip?, inline?)
Color input. Settings other than the title are passed BY NAME (min = 1, group = "Settings"); for numeric inputs min/max/step may also be given positionally. Result: #26a69a
The chosen color.
Note
Defines a color-picker parameter; to leave a line/fill color to the user. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
c = inputColor("#26a69a", "Line Color") plot(close, color=c)
Makes the line color adjustable and plots price in that color.
inputEnum(default, title?, group?, tooltip?, inline?, labels?)
Enum (option) input — opens a LABELED dropdown in the settings panel. default must be an `enum` member (e.g. `Mode.fast`); the dropdown lists every member of that enum with its own label. (A plain string default still works for backward compatibility — it falls back to a single-option dropdown.)
The chosen enum member (fully-qualified string, e.g. "Mode.fast").
Note
Opens a LABELED dropdown in the settings panel (Inputs tab) — the dropdown lists every member of the enum the default belongs to, using each member's own label (not the raw member name). This is built on top of CodeScript's `enum` type (input.enum is not an independent option system) — first declare `enum Name { member1="Label 1", member2="Label 2" }`, then call `inputEnum(Name.member1,...)`.
Defines a bounded list parameter; to choose among a few fixed modes. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
m = inputEnum("mean", "Mode") plot(iff(m == "mean", sma(close, 20), ema(close, 20)))
Branches on a mode-selecting parameter; when it is "mean", the simple average is plotted.
inputFloat(default, title?, min?, max?, step?, group?, tooltip?, inline?)
Float input. Settings other than the title are passed BY NAME (min = 1, group = "Settings"); for numeric inputs min/max/step may also be given positionally.
The decimal number chosen by the user.
Note
Defines a decimal parameter; for fractional values such as a multiplier or threshold. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
k = inputFloat(2.0, "Multiplier") plot(atr(14) * k)
Defines an adjustable multiplier and plots ATR scaled by it.
inputInt(default, title?, min?, max?, step?, group?, tooltip?, inline?)
Integer input. Settings other than the title are passed BY NAME (min = 1, group = "Settings"); for numeric inputs min/max/step may also be given positionally. Result: 14
The integer chosen by the user (the default if none is chosen).
Note
Defines an integer parameter; for counter values such as a window length. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
len = inputInt(20, "Window") plot(sma(close, len))
Defines an adjustable window length and plots the moving average of that length.
inputPrice(default, title?, group?, tooltip?, inline?)
Price input — opens a number field in the settings panel; editable from the Inputs tab. Result: 100
The chosen price level.
Note
Opens a number field in the settings panel (Inputs tab).
A parameter that selects a price level; to let the user set a target or stop line. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
lvl = inputPrice(100.0, "Level") plot(iff(close > lvl, close, na))
Defines an adjustable price level and plots while price is above it.
inputSession(default, title?, group?, tooltip?, inline?)
Session input — opens a text field in the settings panel ("0930-1600" format, typed by hand); editable from the Inputs tab.
The chosen session text.
Note
Opens a text field in the settings panel (Inputs tab) — the user can edit it by typing in "0930-1600" format. The value is in the same format read by session.isMarket and the timeframe functions.
A parameter that selects a trading-session range; to let the user set intraday filters. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
sess = inputSession("0930-1600", "Session") plot(iff(strLength(sess) > 0, close, na))
Defines an adjustable session range and plots price while it is non-empty.
inputSource(source?, title?, group?, tooltip?, inline?)
Source input (close/hl2...).
The chosen price series (the default if none is chosen).
Note
A parameter that selects which price series to use; so an indicator can run on high/hl2 instead of close. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
src = inputSource(close, "Source") plot(sma(src, 20))
Lets the user choose which price series the average is taken over.
inputString(default, title?, group?, tooltip?, inline?, options?)
String input. Settings other than the title are passed BY NAME (min = 1, group = "Settings"); for numeric inputs min/max/step may also be given positionally. Result: BTC
The text entered by the user.
Note
Defines a free-text parameter; such as a mode name or a label. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
mod = inputString("trend", "Mode") plot(iff(mod == "trend", close, open))
Branches on a text parameter; when it is "trend", close is plotted.
inputSymbol(default, title?, group?, tooltip?, inline?)
Symbol search input — opens a text box in the settings panel. Result: BTCUSDT
The chosen symbol text — opens a text box in the settings panel that the user can edit.
Note
Appears in the panel as a text box (keyed by code name/settings key, in the inputs row). Uses the same settings-panel mechanism as the other editable-parameter functions (input/inputInt/inputFloat/inputBool/inputString/inputColor/inputSource).
A parameter that selects a symbol; for taking a symbol name for a comparison or multi-symbol read. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
s = inputSymbol("BTCUSDT", "Symbol") plot(iff(strLength(s) > 0, close, na))
Defines an adjustable symbol name and plots price while it is non-empty.
inputTextArea(default, title?, group?, tooltip?)
Multi-line text input — opens a wide multi-line box in the settings panel; editable from the Inputs tab.
The (possibly multi-line) text entered by the user.
Note
Opens a wide, multi-line text box in the settings panel (Inputs tab) — this is the only difference from the single-line inputString.
Defines a multi-line free-text parameter; for longer inputs such as a note or a list. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
note = inputTextArea("description text", "Note") plot(iff(strLength(note) > 0, close, na))
Defines a multi-line note field and plots price while it is non-empty.
inputTime(default, title?, group?, tooltip?, inline?)
Time input — opens a date+time field in the settings panel (unix-seconds timestamp); editable from the Inputs tab.
The chosen timestamp.
Note
Opens a date+time field in the settings panel (Inputs tab) — the value is a unix-seconds timestamp.
A parameter that selects a date/time; to let the user set time bounds such as a start date. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
t = inputTime(1700000000, "Start") plot(iff(t > 0, close, na))
Defines an adjustable start time and plots price while it is positive.
inputTimeframe(default, title?, group?, tooltip?, inline?)
Timeframe input — opens a standard-TF dropdown in the settings panel. Result: 1D
The chosen timeframe text — opens a standard-TF dropdown in the settings panel that the user can edit.
Note
Appears in the panel as a common-TF dropdown. Uses the same settings-panel mechanism as the other editable-parameter functions (input/inputInt/inputFloat/inputBool/inputString/inputColor/inputSource).
A parameter that selects a timeframe; to let the user set higher-timeframe reads. Opens a control in the editor's settings panel; during computation it returns the selected value (the default).
tf = inputTimeframe("1D", "Timeframe") plot(timeframeInSeconds(tf))
Defines an adjustable timeframe and plots its length in seconds.