Im trying to identify highest high candles and save the difference between the open and close for the last 10 occurrences of these candles into an array, and then get the average of the array. However, I'm having some problems since nan values are being stored in the array, so i'm getting wrong results.
highestHigh = highest(high, 20)
is_high = high >= highestHigh
var float[] HHarray = array.new_float(10) // Array size 10 i.e last 10 candles
if is_high
array.push(HHarray, (close-open))
ArrayAverage = array.sum(HHarray) / array.size (HHarray)
Any idea how this can be fixed? Also, is there a way to view all values stored in an array?
Thanks.