Appearance
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:
| Parameter | What it does |
|---|---|
title | The row's label. Without one the row is labelled from the input's place in the script. |
tooltip | A hint shown beside the row. |
inline | Rows with the same inline text sit on one line. |
group | Rows with the same group text sit under one heading. |
display | Where else the value shows, such as the study's status line: a display.* constant. |
confirm | true asks for the value when the study is added. For a time or a price, the chart asks for a click. |
id | AmenoScript 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/boolAn 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.
| Parameter | Description |
|---|---|
defvalconst int/float/bool/string/color or source-type built-ins | The default value. |
titleconst string | The row's label. |
tooltipconst string | A hint beside the row. |
inlineconst string | Puts rows with the same text on one line. |
groupconst string | Puts rows with the same text under one heading. |
displayconst plot_display | Where else the value shows. |
idAmenoScript onlyconst string | The key a saved setting is held by. |
sweepAmenoScript onlyconst 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 boolA checkbox: true or false.
| Parameter | Default | Description |
|---|---|---|
defvalconst bool | The default. | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.check
AmenoScript only
ameno
input.check(condition, message) → voidStops 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.
| Parameter | Description |
|---|---|
conditionseries bool | What must hold. |
messageseries 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 colorA colour picker.
The value is a colour, transparency included.
| Parameter | Default | Description |
|---|---|---|
defvalconst color | The default colour. | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.enum
pine
input.enum(defval, title, options, tooltip, inline, group, confirm, display, id) → simple enumA 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.
| Parameter | Default | Description |
|---|---|---|
defvalsimple enum | The default field, such as Mode.fast. | |
titleconst string | The row's label. | |
optionstuple of enum fields: [enumName.field1, enumName.field2, ...] | The fields to offer, as [Mode.fast, Mode.slow]. All of them if left out. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst 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 floatA 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.
| Parameter | Default | Description |
|---|---|---|
defvalconst int/float | The default. | |
titleconst string | The row's label. | |
minvalconst int/float | The lowest value the field offers. | |
maxvalconst int/float | The highest value the field offers. | |
stepconst int/float | How much one click of the field's arrows changes it. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. | |
sweepAmenoScript onlyconst array | [from, to, step], the values the Optimizer starts from. No engine reads it. | |
optionstuple 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 floatA price input, as input.price takes one. See AmenoScript's built-ins.
| Parameter | Description |
|---|---|
defvalconst int/float | The default price. |
titleconst 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 intA 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.
| Parameter | Default | Description |
|---|---|---|
defvalconst int | The default. | |
titleconst string | The row's label. | |
minvalconst int/float | The lowest value the field offers. | |
maxvalconst int/float | The highest value the field offers. | |
stepconst int/float | How much one click of the field's arrows changes it. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. | |
sweepAmenoScript onlyconst array | [from, to, step], the values the Optimizer starts from. No engine reads it. | |
optionstuple 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 floatA price field. With confirm = true the chart asks for a click when the study is added, and the click's price is the value.
| Parameter | Default | Description |
|---|---|---|
defvalconst int/float | The default price. | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for a click on the chart when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. | |
sweepAmenoScript onlyconst 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 stringA session field, such as "0930-1600", or a dropdown of sessions when you give options.
| Parameter | Default | Description |
|---|---|---|
defvalconst string | The default session. | |
titleconst string | The row's label. | |
optionstuple of const string values: [val1, val2, ...] | A fixed list of sessions to choose from. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.source
pine
input.source(defval, title, tooltip, inline, group, display, confirm, id) → series floatA 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.
| Parameter | Default | Description |
|---|---|---|
defvalsource-type built-ins | The default price, such as close. | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
displayconst plot_display | Where else the value shows. | |
confirmconst bool | false | Asks for the value when the study is added. |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.string
pine
input.string(defval, title, options, tooltip, inline, group, confirm, display, id) → input stringA text field, or a dropdown when you give options.
| Parameter | Default | Description |
|---|---|---|
defvalconst string | The default text. | |
titleconst string | The row's label. | |
optionstuple of const string values: [val1, val2, ...] | A fixed list to choose from, as ["Fast", "Slow"]. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.symbol
pine
input.symbol(defval, title, tooltip, inline, group, confirm, display, id) → input stringA symbol picker, returning the symbol as text for request.security.
| Parameter | Default | Description |
|---|---|---|
defvalconst string | The default symbol, such as "BTC-USD". | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.text_area
pine
input.text_area(defval, title, tooltip, group, confirm, display, id) → input stringA text box of several lines.
| Parameter | Default | Description |
|---|---|---|
defvalconst string | The default text. | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.time
pine
input.time(defval, title, tooltip, inline, group, confirm, display, id) → input intA 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.
| Parameter | Default | Description |
|---|---|---|
defvalconst int | The default time, such as timestamp("2024-01-01"). | |
titleconst string | The row's label. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for a click on the chart when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |
input.timeframe
pine
input.timeframe(defval, title, options, tooltip, inline, group, confirm, display, id) → input stringA timeframe picker, returning a timeframe string such as "60" or "1D". An empty string means the chart's own.
| Parameter | Default | Description |
|---|---|---|
defvalconst string | The default timeframe. | |
titleconst string | The row's label. | |
optionstuple of const string values: [val1, val2, ...] | A fixed list of timeframes to choose from. | |
tooltipconst string | A hint beside the row. | |
inlineconst string | Puts rows with the same text on one line. | |
groupconst string | Puts rows with the same text under one heading. | |
confirmconst bool | false | Asks for the value when the study is added. |
displayconst plot_display | Where else the value shows. | |
idAmenoScript onlyconst string | The key a saved setting is held by. |