Skip to content
Algo Trade Analytics Docs

array.mode() - Pine Script Function

The function returns the mode of an array’s elements. If there are several values with the same frequency, it returns the smallest value.

array.mode(id) → series float
NameTypeDescription
idarray<int/float>An array object.

The most frequently occurring value from the id array. If none exists, returns the smallest value instead.

  • Returns na if the id array is empty.
//@version=6
indicator("array.mode example")
a = array.new_float(0)
for i = 0 to 9
array.push(a, close[i])
plot(array.mode(a))