Joins an item to the collection it is read from in a for...in loop: for item in array.
in appears in for...in loops: for item in prices runs once per element of prices. The tuple form for [i, item] in prices also gives the index, and for [key, value] in map gives each pair of a map.
It is not a membership test. Pine has no x in array expression; to check whether an array holds a value, use array.includes or array.indexof.
Remarks
- The right-hand side is evaluated once, before the loop starts.
Example
//@version=6
indicator("In loop")
last5 = array.new<float>()
for i = 1 to 5
last5.push(close[i])
found = false
for v in last5
if v == close
found := true
plot(found ? 1 : 0, "Repeat close", color.orange, style = plot.style_columns)
plot(last5.includes(close) ? 1 : 0, "array.includes", color.blue)See also
Runs on Sidechair