array.get() - Pine Script Function
array.get()
Section titled “array.get()”Overview
Section titled “Overview”The function returns the value of the element at the specified index.
Syntax
Section titled “Syntax”array.get(id, index) → series <type>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | any array type | An array object. |
Returns
Section titled “Returns”The array element’s value.
Remarks
Section titled “Remarks”- 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.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("array.get example")a = array.new_float(0)for i = 0 to 9array.push(a, close[i] - open[i])plot(array.get(a, 9))