- The language operator [] :
- provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down - expr1[expr2].
- Returns: A series of values.
- i.e.:open[1] or open[2], close[1], high[1], low[1]
That is how we refference previous candles if we want to make a statement or a check of multiple candles. I want to check the current candle, the previous candle and the one before that.
- The input function:
- adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators.
- Returns: Value of input variable.
- Input is a named string constant for # input type of function
(# = bool, color, float, integer, resolution, session, source, string, symbol, time)
=> input.bool / input.color…
- Strategy function:
a1) generates/activates strategies: i.e. strategy.order, strategy.entry and strategy.exit
a2) strategy.cancel - is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.exit, strategy.entry and strategy.close.
a3) i.e. strategy.direction.all / (#=long, short) - allows strategy to open both long and short positions / or #,
b1) it calculates the result of the strategy we used dependant on the type of strategy used we isolate with commands,
b2) calculates dependant on the commands i.e. strategy.closedtrades - number of trades, which were closed for the whole trading interval.
(# position_size, opentrades, wintrades, losstrades, eventtrades),
b3) i.e. strategy.position_avg_price - calculates the average entry price of current market position.
- The volume variable contains the current bar volume.
Previous values may be accessed with square brackets operator [], e.g. volume[1], volume[2].