How to break or next an object loop?
-
Hi there,
Right now I am working on an object-based project for the first time. My learning curve, so far, about objects in MQL and fxdreema is pretty decent with all of the information that is available on the forum and elsewhere. However, I have been left with some questions. Since I am using a lot of "for each object" blocks, I frequently hop from one loop to another in the project, and now I am in a situation where two loops mess with each other with their data and the wrong stuff happens, etc.
Long story short, how do I break or next a for each object loop like you can with a for each position loop?
Hopefully, you can help me out
-
There is no block breaking that loop, I'm afraid. The only option is adjusting the logic of both of them accordingly.
-
@l-andorrà I am sorry that I did not answer you earlier but I think I have found the logic in the For Each Object loop. You can nest multiple For Each Object loops into another and the loop is always empty and exited. It exits the loop via the yellow dot when the tasks for each object are done via the red dot. If there are no objects on the chart that meet the filters in the for each block, the loop will always exit via the yellow dot. This allows you to count the number of objects on the chart, check if, for example, a rectangle from another timeframe is inside a rectangle on another timeframe etc. I have added a screenshot of what I have now been able to produce using FXDreema: my version of SMC I have used for manual trading

-
@fxpim hey mate, I'm into SMC object-based project as well right now:)
Do you mind sharing the logic you've mentioned on the breaking Objects in the loop via sharing a project link? Thank you in advance
-
@fxpim Very interesting. Could you please share some visual hints on the way you fixed it?
-
@l-andorrà @GeoFX I will try to share it but then I will have to re-create some parts of the project since the project is under contract and pretty big...

-
@GeoFX I think I can explain by now. What you need to do is the following: take a For Each Object loop and store all of the variables you want to check against another object. For me, that would be the upper and lower price coordinates and the beginning of the rectangle. After storing these variables, connect another For Each Object loop to the block that stores the variables and take the condition blocks to check the object of the second loop against the variables you stored in the first loop. The picture shows the block's structure.
So basically: first object loop -> store object variables -> connect second loop -> use condition blocks to check the object properties against the variables you have just stored -> object action for the object of your second loop

-
-
Thank you for sharing.