array.size() - Pine Script Function
array.size()
Section titled “array.size()”Overview
Section titled “Overview”The function returns the number of elements in an array.
Syntax
Section titled “Syntax”array.size(id) → series intParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| id | any array type | An array object. |
Returns
Section titled “Returns”The number of elements in the array.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("array.size example")a = array.new_float(0)for i = 0 to 9array.push(a, close[i])// note that changes in slice also modify original arrayslice = array.slice(a, 0, 5)array.push(slice, open)// size was changed in slice and in original arrayplot(array.size(a))plot(array.size(slice))