[] - Pine Script Operator
[]
Overview
Section titled “Overview”Series subscript. Provides access to previous values of series expr1. expr2 is the number of bars back, and must be numerical. Floats will be rounded down.
Syntax
Section titled “Syntax”expr1[expr2]Returns
Section titled “Returns”A series of values.
Example
Section titled “Example”//@version=6indicator("[]")// [] can be used to "save" variable value between barsa = 0.0 // declare `a`a := a[1] // immediately set current value to the same as previous. `na` in the beginning of historyif high == low // if some condition - change `a` value to another a := lowplot(a)