Skip to content
Algo Trade Analytics Docs

array.get() - Pine Script Function

The function returns the value of the element at the specified index.

array.get(id, index) → series <type>
NameTypeDescription
idany array typeAn array object.

The array element’s value.

  • If the index is positive, the function counts forwards from the beginning of the array to the end. The index of the first element is 0, and the index of the last element is array.size() - 1. If the index is negative, the function counts backwards from the end of the array to the beginning. In this case, the index of the last element is -1, and the index of the first element is negative array.size(). For example, for an array that contains three elements, all of the following are valid arguments for the index parameter: 0, 1, 2, -1, -2, -3.
//@version=6
indicator("array.get example")
a = array.new_float(0)
for i = 0 to 9
array.push(a, close[i] - open[i])
plot(array.get(a, 9))