BarsSinceCompare( past_array, compare, current_array );
You would call it like this
BarsSinceCompare( Close, ">", Close ); // get bars since close was last time higher than current close
BarsSinceCompare( Low, ">", Close ); // get bars since low was last time higher than current close
BarsSinceCompare( Low, ">=", Close ); // get bars since low was last time higher than or equal than current close
BarsSinceCompare( High, "<=", Low ); // get bars since high was lower than or equal than current low
Or maybe BarsSinceComparePast() or BarsSinceLastTime() would be better name ?
You might wonder why do I care about the name so much?
Well, I don't want to create confusion among users and don't want this function to be abused when it is not needed at all.
Example: even @fxshrat mentioned this:
two function arguments... 2nd one being either scalar
Now, this function is strictly for ARRAYS and ARRAYS ONLY.
Using it for scalars make no sense because if one of things being compared is a scalar you should just use much faster BarsSince() function
x = BarsSince( array > 5 ); // if one arg is a scalar BarsSince does the job perfectly
The point is that BarsSinceCompare() function is computationally intensive (complexity O(n2)), therefore it should only be used when really needed (when BOTH arguments are arrays)