End loop once condition is met
-
Hello, I use an indicator that draws an object (not available via buffer, but I can get it via colour) on swing highs and lows.
I want to get the candle ID of the most recent object, but ONLY if it is higher (for swing high object) or lower (for swing low object) than the current candle close. The loop should run until the price-is-higher and price-is-lower conditions are met, and then write the 2 candle IDs into variables. How do I add this condition into the loop, and stop it once the first object that meets the condition is met?
Here is what I have so far; any help is highly appreciated.
-
@nk0815 I would separate both searching loops into different block trees. Then a third independent tree would do the comparison. You current structure will not search fopr the green object unlest the maroon one is first identifed. And I guess that's not happening all the time.
-
Thank you for your reply, that brought me thinking quite a bit further.
I think I will need a custom MQL code block to start the loop. I will open a separate post for this as it is not really related to what I have written here first.
Have a good day

-
@nk0815 You're welcome.