What's the best way to check if an array has same value continuously for past 'n' occurences?

I was thinking of " x - ref(x,-1) ==0",

but how to see if there's 0 for past 'n' bars?

sorry if this is a stupid question.

What's the best way to check if an array has same value continuously for past 'n' occurences?

I was thinking of " x - ref(x,-1) ==0",

but how to see if there's 0 for past 'n' bars?

sorry if this is a stupid question.

Say you're looking at ROC as the array.

```
x = ROC(C,1)>0 or ROC(C,1)<0;
y = sum(x,10)==0; // number of instances in the previous 10 bars where ROC changed = zero.
```

3 Likes

Thanks a lot, C_M, for pointing in the right direction. Had used "sum" earlier but did not think of it this way. Glad you could help. Really appreciate it.