Finding multiple bars in a row with the same high


Please forgive my newness to Optuma scripting... no idea where to start for this one.

I'm keen to run a scan that shows multiple bars in a row that have the same high (or low). A bonus would be if it could have a tolerance, as in within x% or points of each other. Image below for reference, don't need a blue line, just a pointer as to where it is.



Hi Rhiannon,

You can use the following in a Show Bar, which will highlight consecutive highs:

HIGH() == HIGH(1)

where HIGH() is the current bar, and HIGH(1) is the previous bar. To build a 1% tolerance you could do something like:

(HIGH() > (HIGH(1)*0.99)) and (HIGH() < (HIGH(1)*1.01))


For a scan you can use the BARSTRUE() function (Lecture 3 here), so where at least 3 highs are within 1% of each other:

BARSTRUE((HIGH() > (HIGH(1)*0.99)) and (HIGH() < (HIGH(1)*1.01)), LOOKBACK=3) == 3