Unfortunately the EA builder is weak when it comes to mathematical calculations, this thing is normally done by the indicators themselves.
It's easier to write such a custom code instead of building it with blocks, because this some normal "for" or "while" loop with few extra variables to control it. I don't know how to make things like this with blocks... I mean... there are already some loops available (for example this big category with pink blocks), but many people have problems understanding how to deal with this, even if it's not that complicated.
Otherwise in some loop you want to check indicator values for the last candles, having some variable to count and starting from 0. When the detected value is lower/bigger than something - break the loop. Then use the value from the counter. Additionaly, to optimize things, add some "once per bar" functionality. Or something else.