Custom MQL code to start a loop
-
Hello, for my current EA project I need to start a loop with multiple conditions. As the "For each object" block doesn't support additional conditions, I would be forever thankful if somebody could tell me how to write the following statements into a custom MQL code block to start a loop:
For each object
Filter by color: Maroon
Additional filters (not available in "for each object" block):
Object price level is above last M15 candle close (candle ID 1)
Every candle after object (or: where age is younger than the object) closed below object price level
Loop settings: Z to A
Not more than 1 objectThanks a lot in advance if somebody can point me in the right direction

-
@nk0815 Use multiple blocks, each block only passes when true so when all conditions are true the next block activates.
-
I tried to achieve it that way, however, I have a problem with "Not more than 1 object" if it has to check multiple times to find one that matches the conditions. It would still pick the same first one in Maroon color over and over again I assume? Or do I understand this wrong?
-
@nk0815 If your indicator is only recognised by colour when it appears I would record the candle ID and start counting once per bar.
-
I still wouldn't know how to solve the issue in that case. Maybe it is clearer with the project link

https://fxdreema.com/shared/DiYH5WiW
My guess is that it will either always pick the same object and fail with the conditions , or it would run through way too many as it doesn't stop once it drew the lines at the end. Or is there some block to stop a loop that I can add at the end?
-
Update: https://fxdreema.com/shared/Hjrqm45Dc
The loop counter allows 1 pass per bar in this case?
-
@nk0815 Yes your right, try this https://fxdreema.com/shared/a3nHBfaFd will show in the comment the candle ID's so you can count and see if the correct candles are recorded, you could then use the adjust to find the high/low in a range of the object.
-
Thanks so much!