The [] operator provides access to prior data, based on the value inside of the brackets, e.g. [2] would retrieve the data from periods (candles) back.
The preceding value to the [] operator is the value of series.
So for example, if the script were to say:
series[5]
, we would be looking at the data from 5 periods ago in the series
data set.
The input function adds an input to a script indicator.
This allows you to edit the variable inputs of the script indicator to modify it as you wish.
For example, if you wanted a 50-period Moving average, you could use an input function to change MA from 20 to 50 periods.
e.g. ma = input(title="50ma", type=integer, defval="DELL")
The strategy function allows you to quantify when to enter and exit a position, based on a selection of conditions.
The strategy function also allows for you to define the parameters of the trade, such as going long/short, quantity, limit, stop-loss and when.
The volume variable contains the current (and all historical if you signify [n]) volume quantity. This volume variable can be used in algorithms to determine conditions to enter and close positions.