millionchart
فارسی

Inputs

Settings that appear in the indicator's panel. Every input type, the options each takes, groups and tooltips, and which input features are not available yet.

An input is a setting. It appears in the indicator's settings panel, the member can change it without touching the code, and the script runs again with the new value. Inputs go at the top level of the file, near the top, or inside a group.

Declaring an input#

Cuprel
indicator "Input forms"
    edition = 1

input length: int = 20, name = "Length", min = 1, max = 200, tooltip = "Bars the average looks at"
input mult: float = 2.0, name = "Multiplier", min = 0.1, step = 0.1
input smooth: bool = true, name = "Smooth"
let average = tech.sma(close, length)
let smoothed = tech.ema(average, 3)
plot(if smooth then smoothed else average, name = "Average")
plot(average * mult, name = "Scaled")

The shape is input name: type = default, option = value, .... The default must be a constant: a value you write (a number, a text, a colour, true, false, a time) or arithmetic on such values, never something that changes from bar to bar such as bar.index. Inside the script the name is an ordinary value: length is 20 until the member changes it.

The types#

TypeValueNotes
intwhole numbermin, max, step, options
floatnumbermin, max, step, options
booltrue or falsea switch
texttextoptions for a dropdown, multiline = true for a text area
colora coloura colour picker
sourcea price seriesone of open, high, low, close, hl2, hlc3, ohlc4, hlcc4
timeframe (or tf)a timeframe such as "60" (minutes) or "1D"options
symbola symbol name
sessionhours such as "0800-1600"options
timean instantwritten like @2026-01-01T00:00Z
pricea number in price units
an enumone membershown as a dropdown with the members' labels
Cuprel
indicator "Several types"
    edition = 1
    display = price

enum Mode
    fast = "Fast"
    slow = "Slow"
input mode: Mode = Mode.fast, name = "Mode"
input src: source = close, name = "Source"
input line_color: color = #2962ff, name = "Line colour"
input tf: tf = "60", name = "Other timeframe"
let length = match mode
    Mode.fast => 10
    Mode.slow => 40
let other = data.series(tf, tech.ema(src, length), symbol = symbol.id)
plot(other, name = "Average on the other timeframe", color = line_color)

A source input is how an indicator lets the member choose what it is applied to. A timeframe input can be passed straight to data.series.

A dropdown#

options turns a number or a text into a list of choices. Make the default one of them.

Cuprel
indicator "Dropdown"
    edition = 1

input kind: text = "EMA", name = "Kind", options = ["EMA", "SMA", "WMA"]
input length: int = 20, name = "Length", options = [10, 20, 50, 100]
let ema = tech.ema(close, length)
let sma = tech.sma(close, length)
let wma = tech.wma(close, length)
let average = match kind
    "EMA" => ema
    "SMA" => sma
    _ => wma
plot(average, name = "Average")

Groups, tooltips and short forms#

group "Name" is a block. The inputs indented under it are shown together under that heading. A /// line above an input is its tooltip. When the type can be read from the default, you can leave it out, and you can write the label (the name) as the second value, without name =:

Cuprel
indicator "Grouped inputs"
    edition = 1

group "Signal"
    /// How many bars the oscillator looks back
    input length = 14, "Length"
    input src: source = close, name = "Source"
group "Levels"
    input upper = 70.0, "Overbought"
    input lower = 30.0, "Oversold"
let osc = tech.rsi(src, length)
plot(osc, name = "RSI", color = color.purple)
level(upper, name = "Upper level")
level(lower, name = "Lower level")

A short form such as input length = 14 is a whole number, so its type is int. If you mean a decimal, write 14.0 or say float.

Inputs are live#

An input is not a constant. When the member changes it, the script runs again from the first bar. That includes the settings of a strategy's header (commission, size, spread), so a member can try a cost and see the result. A few call options must still be written in the script and cannot take an input: the key, once and cooldown of an alert, and the line width, style and offset of a plot. The engine refuses the first group and keeps the default of the second with a warning.

The id of an input#

An input's id is its name. The saved chart finds the value again by the id, so changing its label (the name text) or its language never loses a setting. Give id = "other" to use a different id, and was = "old_name" after you rename an input, so a value saved under the old name is carried over. Ids covers this.

Mistakes the editor catches#

An option the input does not know is an error, with the list of those it does:

Cuprel · error E3130
indicator "Misspelled option"
    edition = 1

input length: int = 20, name = "Length", minimum = 1
plot(length)

An input with neither a type nor a default has nothing to go on:

Cuprel · error E2030
indicator "Nothing to go on"
    edition = 1
input length
plot(length)

Show an input only when it applies#

show_if shows an input in the settings only while a rule is true. The rule can name other inputs (also ones declared further down), constants and members of an enum; it cannot name a price, a series or a value the script works out. A hidden input still gives its value to the script.

Cuprel
indicator "Show only when it applies"
    edition = 1

enum Style
    manual = "Manual"
    auto = "Auto"

input style: Style = Style.auto, "Style"
input smoothing: int = 5, "Smoothing", min = 1, max = 50, show_if = style == Style.manual
plot(tech.sma(close, smoothing))

A rule that names anything else is the error E3133, and inputs whose show_if rules lead back to each other are E3134:

Cuprel · error E3133
indicator "A rule that names a price"
    edition = 1

input depth: int = 3, "Depth", show_if = close > 0
plot(depth)
Cuprel · error E3134
indicator "Two inputs that wait for each other"
    edition = 1

input a: int = 1, "A", show_if = b > 0
input b: int = 1, "B", show_if = a > 0
plot(a + b)

Check a value#

check = rule, "message" shows the message under the field while the rule is false. In this release the check is only a message: the script still runs, so a value the check refuses is not stopped. The rule follows the same limits as show_if.

Cuprel
indicator "Check a value"
    edition = 1

input stop: float = 1.5, "Stop", min = 0.1, check = stop <= limit, "The stop is above the limit"
input limit: float = 3, "Limit"
plot(close - stop)

A list, and a text of several lines#

list<T> is an input that holds several values; T is int, float, text or time. The default is a list written out, with at most 200 items. In the script the input is an array: read an item with .at(i). A text input with multiline = true is a text of several lines.

Cuprel
indicator "A list as an input"
    edition = 1

input levels: list<float> = [1.5, 2.5], "Levels"
input note: text = "first line", "Notes", multiline = true
plot(close + levels.at(0), name = "First level")

The settings keep a list as text, at most 2,000 characters. If a stored list cannot be read as a list, the script gets an empty list and the engine says so with the warning W-ENGINE-LIST-INPUT.

Not available yet#

The preset, bind and secret inputs belong to a later edition of the language. They are refused now, so that a script written for them cannot run with the wrong meaning:

Cuprel · error E9002
indicator "Not available yet"
    edition = 1
preset p
plot(close)

See also: Ids, Values and types, Your first strategy.