fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Custom MQL code to start a loop

    Questions & Answers
    2
    8
    632
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      nk0815 last edited by nk0815

      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 object

      Thanks a lot in advance if somebody can point me in the right direction 🙂

      jstap 1 Reply Last reply Reply Quote 0
      • jstap
        jstap @nk0815 last edited by

        @nk0815 Use multiple blocks, each block only passes when true so when all conditions are true the next block activates.

        Learn fxDreema Without the Wait!

        My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

        The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

        Don’t miss out

        Click here➡️ https://mybook.to/fxDreema to get your copy today!

        Enjoy! 😊

        1 Reply Last reply Reply Quote 0
        • N
          nk0815 last edited by

          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?

          jstap 1 Reply Last reply Reply Quote 0
          • jstap
            jstap @nk0815 last edited by

            @nk0815 If your indicator is only recognised by colour when it appears I would record the candle ID and start counting once per bar.

            Learn fxDreema Without the Wait!

            My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

            The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

            Don’t miss out

            Click here➡️ https://mybook.to/fxDreema to get your copy today!

            Enjoy! 😊

            N 1 Reply Last reply Reply Quote 0
            • N
              nk0815 @jstap last edited by nk0815

              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?

              1 Reply Last reply Reply Quote 0
              • N
                nk0815 last edited by

                Update: https://fxdreema.com/shared/Hjrqm45Dc

                The loop counter allows 1 pass per bar in this case?

                jstap 1 Reply Last reply Reply Quote 0
                • jstap
                  jstap @nk0815 last edited by

                  @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.

                  Learn fxDreema Without the Wait!

                  My comprehensive book, available on Amazon, is packed with examples and invaluable insights to help you fast-track your learning journey.

                  The paperback and hardback editions include MT4 & MT5 QR codes for easy access to all prebuilt projects and robots, including my latest gold trading robot!

                  Don’t miss out

                  Click here➡️ https://mybook.to/fxDreema to get your copy today!

                  Enjoy! 😊

                  1 Reply Last reply Reply Quote 0
                  • N
                    nk0815 last edited by

                    Thanks so much!

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post

                    Online Users

                    R
                    P

                    9
                    Online

                    146.7k
                    Users

                    22.4k
                    Topics

                    122.6k
                    Posts

                    Powered by NodeBB Forums | Contributors