input¶
- input_type¶
- Enum Items
input.integer – Integer value.
input.double – Numeric value.
input.boolean – Boolean value. Presented as a checkbox.
input.active – Currently not supported.
input.candle_duration – Currently not supported.
input.string – String value.
input.integer_selection – Selection from the predefined list of integers.
input.double_selection – Selection from the predefined list of numerics.
input.string_selection – Selection from the predefined list of strings.
input.color – Color value.
input.line_width – Line width value.
input.plot_visibility – Plot visibility settings. Presented as a checkbox.
input.plot_shape_style – Shape style value. Not supported on mobile platforms.
input.plot_shape_size – Shape size value. Not supported on mobile platforms.
input.plot_shape_location – Shape location value. Not supported on mobile platforms.
- input([default][, name][, type][, options])[has-table-overload]¶
- input([default][, name][, type][, min][, max][, step])[has-table-overload]¶
- Parameters
default – Default return value for the input. Default value depends on
type
.name (
string
) – Name of the input. Can be a localisation key. Default value is""
.type (
input_type
) – Input type. Default value depends onvalue
.min – Minimal allowed value. Default value depends on
type
.max – Maximal allowed value. Default value depends on
type
.step – Value step. Default value depends on
type
.options (
array[integer]
) – Array of options for the input.integer_selection, input.double_selection, input.string_selection. Default value isnil
.
- Returns
Same type, as
default
input creates a user-modifiable value to fine tune the instrument. Inputs can control both the evaluation and the visual settings of the indicator. To execute successfully input must have a type set either explicitly or deduced from the default value. Thus either default or type must be present in the invocation. Not all input types can be manually deduced, these types must be set explicitly.
Indicator Settings
type
default
min
max
step
input.integer
0
\(-2^{63}-1\)
\(2^{63}-1\)
1
input.double
0
\(-1.8e+308\)
\(1.8e+308\)
1
input.boolean
false
N/A
N/A
N/A
input.string
""
N/A
N/A
1
input.integer_selection
1
N/A
N/A
array[integer]
input.double_selection
1
N/A
N/A
array[double]
input.string_selection
1
N/A
N/A
array[string]
Visual Settings
type
default
input.color
“white”
input.line_width
1
input.plot_visibility
true
Source and Average Selectors
For convenience, there are predefined arrays to create source and moving average selectors.
Input Sources for overlay instruments:
src_idx = input(inputs.close, "Source", input.string_selection, inputs.titles_overlay) local source = inputs [src_idx]
Input Sources for standalone instruments:
src_idx = input(inputs.close, "Source", input.string_selection, inputs.titles) local source = inputs [src_idx]
Moving Averages:
avg_idx = input (averages.sma, "Average", input.string_selection, averages.title) local average = averages [avg_idx]
Example:
period = input (9, "front.period", input.integer, 1) source = input (1, "front.ind.source", input.string_selection, inputs.titles) plot (sma (inputs [source], period), "SMA")