Skip to content

input ​

How do you let a reader change a length or a colour without editing your script? Declare it with an input.* call. Each call adds a row to the study's Settings, and returns the value set there, or defval until someone changes it.

pine
//@version=6
indicator("Moving average, with settings", overlay = true)
src = input.source(close, "Source")
len = input.int(20, "Length", minval = 1, group = "Average")
col = input.color(color.orange, "Colour", group = "Average")
plot(ta.sma(src, len), "SMA", col)

Every input is fixed for the whole run: its value is the same on every bar, and changing a setting runs the script again from the first bar. A setting is saved against the input's id if it has one, else its title, else its place in the script, so a renamed or moved input can lose a saved value. Two inputs with the same title share no setting: the first one owns the title. See inputs.

The parameters every input shares lay out its Settings row:

ParameterWhat it does
titleThe row's label. Without one the row is labelled from the input's place in the script.
tooltipA hint shown beside the row.
inlineRows with the same inline text sit on one line.
groupRows with the same group text sit under one heading.
displayWhere else the value shows, such as the study's status line: a display.* constant.
confirmtrue asks for the value when the study is added. For a time or a price, the chart asks for a click.
idAmenoScript only. The key a saved setting is held by, so the input can move or be renamed without losing it. Two inputs with one id stop the script.

input ​

pine
input(defval, title, tooltip, inline, group, display, id, sweep) → input color/string/int/float/bool

An input whose kind follows its default: a number, a bool, a string, a colour, or a source when the default is a price such as close.

A whole-number float default makes an int input

input(1.0) is read as an int input here, so a value set in Settings is rounded to a whole number. Use input.float(1.0) to keep a float.

ParameterDescription
defval
const int/float/bool/string/color or source-type built-ins
The default value.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.
sweepAmenoScript only
const array
[from, to, step], the values the Optimizer starts from. No engine reads it.

input.bool ​

pine
input.bool(defval, title, tooltip, inline, group, confirm, display, id) → input bool

A checkbox: true or false.

ParameterDefaultDescription
defval
const bool
The default.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.check ​

AmenoScript only
ameno
input.check(condition, message) → void

Stops the script on its first bar, with message, when condition is false. See inputs in AmenoScript.

Use it to refuse a combination of settings that can't work, so the reader sees your words instead of a wrong chart. It returns nothing.

ParameterDescription
condition
series bool
What must hold.
message
series string
What the reader sees when it doesn't.
ameno
indicator("Two averages, checked", overlay = true)
fast = input.int(10, "Fast")
slow = input.int(30, "Slow")
input.check(fast < slow, "Fast must be shorter than slow") // AmenoScript only
plot(ta.ema(close, fast))
plot(ta.ema(close, slow))

input.color ​

pine
input.color(defval, title, tooltip, inline, group, confirm, display, id) → input color

A colour picker.

The value is a colour, transparency included.

ParameterDefaultDescription
defval
const color
The default colour.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.enum ​

pine
input.enum(defval, title, options, tooltip, inline, group, confirm, display, id) → simple enum

A dropdown of an enum's fields, returning the field chosen.

Declare the enum with enum, and give its fields titles to show those in the list. options narrows the list to some fields.

ParameterDefaultDescription
defval
simple enum
The default field, such as Mode.fast.
title
const string
The row's label.
options
tuple of enum fields: [enumName.field1, enumName.field2, ...]
The fields to offer, as [Mode.fast, Mode.slow]. All of them if left out.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.
pine
//@version=6
indicator("Pick an average", overlay = true)
enum Kind
    sma = "Simple"
    ema = "Exponential"
kind = input.enum(Kind.ema, "Average")
sma = ta.sma(close, 20) // both run on every bar, so neither misses bars
ema = ta.ema(close, 20)
plot(kind == Kind.sma ? sma : ema)

input.float ​

pine
input.float(defval, title, minval, maxval, step, tooltip, inline, group, confirm, display, id, sweep) → input float
input.float(defval, title, options, tooltip, inline, group, confirm, display, id, sweep) → input float

A number field for a float, with optional bounds and step, or a dropdown when you give options.

minval, maxval and step shape the Settings field; the script reads whatever value is set.

ParameterDefaultDescription
defval
const int/float
The default.
title
const string
The row's label.
minval
const int/float
The lowest value the field offers.
maxval
const int/float
The highest value the field offers.
step
const int/float
How much one click of the field's arrows changes it.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.
sweepAmenoScript only
const array
[from, to, step], the values the Optimizer starts from. No engine reads it.
options
tuple of const int/float values: [val1, val2, ...]
A fixed list to choose from, as [0.5, 1.0, 2.0], instead of a field.

input.hline ​

AmenoScript only
ameno
input.hline(defval, title) → input float

A price input, as input.price takes one. See AmenoScript's built-ins.

ParameterDescription
defval
const int/float
The default price.
title
const string
The row's label.

input.int ​

pine
input.int(defval, title, minval, maxval, step, tooltip, inline, group, confirm, display, id, sweep) → input int
input.int(defval, title, options, tooltip, inline, group, confirm, display, id, sweep) → input int

A number field for a whole number, with optional bounds and step, or a dropdown when you give options.

A value set in Settings is rounded to a whole number. minval, maxval and step shape the field; the script reads whatever value is set.

ParameterDefaultDescription
defval
const int
The default.
title
const string
The row's label.
minval
const int/float
The lowest value the field offers.
maxval
const int/float
The highest value the field offers.
step
const int/float
How much one click of the field's arrows changes it.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.
sweepAmenoScript only
const array
[from, to, step], the values the Optimizer starts from. No engine reads it.
options
tuple of const int values: [val1, val2, ...]
A fixed list to choose from, as [10, 20, 50], instead of a field.

input.price ​

pine
input.price(defval, title, tooltip, inline, group, confirm, display, id, sweep) → input float

A price field. With confirm = true the chart asks for a click when the study is added, and the click's price is the value.

ParameterDefaultDescription
defval
const int/float
The default price.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for a click on the chart when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.
sweepAmenoScript only
const array
[from, to, step], the values the Optimizer starts from. No engine reads it.

input.session ​

pine
input.session(defval, title, options, tooltip, inline, group, confirm, display, id) → input string

A session field, such as "0930-1600", or a dropdown of sessions when you give options.

ParameterDefaultDescription
defval
const string
The default session.
title
const string
The row's label.
options
tuple of const string values: [val1, val2, ...]
A fixed list of sessions to choose from.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.source ​

pine
input.source(defval, title, tooltip, inline, group, display, confirm, id) → series float

A dropdown of the bar's prices: open, high, low, close, hl2, hlc3, hlcc4, ohlc4 and volume, or another study's plot on the same chart.

Unlike the other inputs, it returns a series, the chosen price on each bar.

ParameterDefaultDescription
defval
source-type built-ins
The default price, such as close.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
display
const plot_display
Where else the value shows.
confirm
const bool
falseAsks for the value when the study is added.
idAmenoScript only
const string
The key a saved setting is held by.

input.string ​

pine
input.string(defval, title, options, tooltip, inline, group, confirm, display, id) → input string

A text field, or a dropdown when you give options.

ParameterDefaultDescription
defval
const string
The default text.
title
const string
The row's label.
options
tuple of const string values: [val1, val2, ...]
A fixed list to choose from, as ["Fast", "Slow"].
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.symbol ​

pine
input.symbol(defval, title, tooltip, inline, group, confirm, display, id) → input string

A symbol picker, returning the symbol as text for request.security.

ParameterDefaultDescription
defval
const string
The default symbol, such as "BTC-USD".
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.text_area ​

pine
input.text_area(defval, title, tooltip, group, confirm, display, id) → input string

A text box of several lines.

ParameterDefaultDescription
defval
const string
The default text.
title
const string
The row's label.
tooltip
const string
A hint beside the row.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.time ​

pine
input.time(defval, title, tooltip, inline, group, confirm, display, id) → input int

A date and time, in milliseconds since 1970. With confirm = true the chart asks for a click when the study is added, and the click's bar time is the value.

ParameterDefaultDescription
defval
const int
The default time, such as timestamp("2024-01-01").
title
const string
The row's label.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for a click on the chart when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

input.timeframe ​

pine
input.timeframe(defval, title, options, tooltip, inline, group, confirm, display, id) → input string

A timeframe picker, returning a timeframe string such as "60" or "1D". An empty string means the chart's own.

ParameterDefaultDescription
defval
const string
The default timeframe.
title
const string
The row's label.
options
tuple of const string values: [val1, val2, ...]
A fixed list of timeframes to choose from.
tooltip
const string
A hint beside the row.
inline
const string
Puts rows with the same text on one line.
group
const string
Puts rows with the same text under one heading.
confirm
const bool
falseAsks for the value when the study is added.
display
const plot_display
Where else the value shows.
idAmenoScript only
const string
The key a saved setting is held by.

AmenoScript is compatible with Pine Script v6. Pine Script is a trademark of TradingView, Inc., which has no part in AmenoScript.