CODESCRIPT

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.

default
number
Default value.
min
number
Optional. Lower bound for optimization.
max
number
Optional. Upper bound for optimization.
step
number
Optional. Optimization step size.
name
string
Optional. Parameter name (shown in the results table).
group
string
Optional (given by name only). A constant string — shows this input under a titled section with that name in the settings panel; inputs sharing a group are grouped together.
tooltip
string
Optional (given by name only). A constant string — adds a help icon next to the input, shown on hover.
inline
string
Optional (given by name only). A constant string — shows inputs that share the same inline value SIDE BY SIDE (on one row) in the panel.
options
array
Optional (given by name only). A fixed-value dropdown; if given, it replaces min/max/step (the two are mutually exclusive). Works for both text and numeric inputs.

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.

CODESCRIPT
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).

default
bool
The default state (true/false).
title
string
Optional. The checkbox label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
color
The default color (#rrggbb).
title
string
Optional. The color-picker label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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").

default
string
An `enum` member (e.g. `Mode.fast`). A plain string is also accepted for backward compatibility (falls back to a single-option dropdown).
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.
labels
array
Optional. The labels shown in the dropdown. Left out, the labels from the enum definition are used. The option's VALUE does not change (that is the storage key); only the visible text is picked, so options can be translated.

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).

CODESCRIPT
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.

default
number
The decimal default value.
title
string
Optional. The label shown in the panel.
min
number
Optional. Smallest value the user may enter.
max
number
Optional. Largest value the user may enter.
step
number
Optional. Increment used by the up/down arrows.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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).

default
number
The integer default value.
title
string
Optional. The label shown in the panel.
min
number
Optional. Smallest value the user may enter.
max
number
Optional. Largest value the user may enter.
step
number
Optional. Increment used by the up/down arrows.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
number
The default price level.
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
string
The default session range ("0930-1600").
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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).

source
series
The default price series (close, hl2, etc.).
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
string
The default text.
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.
options
array
Optional. When given, the input becomes a DROPDOWN limited to these values.

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).

CODESCRIPT
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.

default
string
The default symbol.
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
string
The default multi-line text.
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.

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).

CODESCRIPT
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.

default
number
The default timestamp.
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
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.

default
string
The default timeframe ("1D", "4h").
title
string
Optional. The field label.
group
string
Optional. Heading this input is grouped under in the settings dialog. Inputs sharing a `group` appear together.
tooltip
string
Optional. Help text shown when hovering the (?) icon next to the input.
inline
string
Optional. Inputs sharing the same `inline` value are laid out side by side on one row.

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).

CODESCRIPT
tf = inputTimeframe("1D", "Timeframe")
plot(timeframeInSeconds(tf))

Defines an adjustable timeframe and plots its length in seconds.