Input
input
input
Definition: Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function automatically detects the type of the argument used for 'defval' and uses the corresponding input widget.
Syntax:
input(defval, title) → input bool
input(defval, title) → input int
input(defval, title) → input float
input(defval, title) → series float
Returns:
Value of input variable.
Arguments:
defval
(const int/float/bool or source-type built-ins)
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where script users can change it. Source-type built-ins are built-in series float variables that specify the source of the calculation: close
, hlc3
, etc.
title
const string
Title of the input. If not specified, the variable name is used as the input's title. If the title is specified, but it is empty, the name will be an empty string.
Example:
//@version=5
indicator("input")
i_switch = input(true, "On/Off")
plot(i_switch ? open : na)
i_len = input(7, "Length")
i_src = input(close, "Source")
plot(ta.sma(i_src, i_len))
i_border = input(142.50, "Price Border")
input.source
input.source
Definition: Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a dropdown that allows the user to select a source for the calculation, e.g. close, hl2, etc. The user can also select an output from another indicator on their chart as the source.
Syntax:
input.source(defval, title) → series float
Returns:
Value of input variable.
Arguments:
defval
(open/high/low/close/hl2/hlc3/ohlc4/hlcc4)
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where the user can change it.
title
const string
Title of the input. If not specified, the variable name is used as the input's title. If the title is specified, but it is empty, the name will be an empty string.
Example:
//@version=5
indicator("input.source")
i_src = input.source(close, "Source")
plot(i_src)
Remarks: Result of input.source function always should be assigned to a variable, see examples above.
input.float
input.float
input.float
is used to add an input to the Inputs tab of your script's Settings, which provides configuration options to script users. This function adds a field for a float input to the script's inputs.
Syntax:
pythonCopy codeinput.float(defval, title, minval, maxval, step) → input float
Returns:
cssCopy codeValue of input variable.
Arguments:
defval
const int/float
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where script users can change it. When a list of values is used with the options
parameter, the value must be one of them.
title
const string
Title of the input.
minval
const int/float
Minimal possible value of the input variable. Optional.
maxval
const int/float
Maximum possible value of the input variable. Optional.
step
const int/float
Step value used for incrementing/decrementing the input. Optional. The default is 1.
Example:
//@version=5
indicator("input.float", overlay=true)
i_angle1 = input.float(0.5, "Sin Angle", minval=-3.14, maxval=3.14, step=0.02)
plot(math.sin(i_angle1) > 0 ? close : open, "sin", color=color.green)
i_angle2 = input.float(0, "Cos Angle", options=[-3.14, -1.57, 0, 1.57, 3.14])
plot(math.cos(i_angle2) > 0 ? close : open, "cos", color=color.red)
input.int
input.int
input.int
is used to add an input to the Inputs tab of your script's Settings, which provides configuration options to script users. This function adds a field for an integer input to the script's inputs.
Syntax:
input.int(defval, title, minval, maxval, step) → input int
Returns:
Value of input variable.
Arguments:
defval
const int
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where script users can change it. When a list of values is used with the options
parameter, the value must be one of them.
title
const string
Title of the input.
minval
const int
Minimal possible value of the input variable. Optional.
maxval
const int
Maximum possible value of the input variable. Optional.
step
const int
Step value used for incrementing/decrementing the input. Optional. The default is 1.
Example:
//@version=5
indicator("input.int", overlay=true)
i_len1 = input.int(10, "Length 1", minval=5, maxval=21, step=1)
plot(ta.sma(close, i_len1))
i_len2 = input.int(10, "Length 2", options=[5, 10, 21])
plot(ta.sma(close, i_len2))
input.session
input.session
input.session
is used to add an input to the Inputs tab of your script's Settings, which provides configuration options to script users. This function adds two dropdowns that allow the user to specify the beginning and end of a session.
Syntax:
input.session(defval, title) → input session
Returns:
String value of input variable.
Arguments:
defval
const string
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where script users can change it. When a list of values is used with the options
parameter, the value must be one of them.
title
const string
Title of the input.
Example:
//@version=5
indicator("input.session", overlay=true)
i_time = input.session("0930-1630", "Input Time",options=["0930-1600", "1300-1700", "1700-2100"])
input.bool
input.bool
Definition: Adds an input to the Inputs tab of your script's Settings, which allows you to provide configuration options to script users. This function adds a checkmark to the script's inputs.
Syntax:
pythonCopy codeinput.bool(defval, title) → input bool
Returns:
cssCopy codeValue of input variable.
Arguments:
defval
const bool
Determines the default value of the input variable proposed in the script's "Settings/Inputs" tab, from where the user can change it.
title
const string
Title of the input.
Example:
csharpCopy code//@version=5
indicator("input.bool", overlay=true)
i_switch = input.bool(true, "On/Off")
plot(i_switch ? open : na)
Last updated