Skip to content
Algo Trade Analytics Docs

array.lastindexof() - Pine Script Function

The function returns the index of the last occurrence of the value, or -1 if the value is not found.

array.lastindexof(id, value) → series int
NameTypeDescription
idany array typeAn array object.

The index of an element.

//@version=6
indicator("array.lastindexof example")
a = array.new_float(5,high)index = array.lastindexof(a, high)
plot(index)