fxDreema

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

    How to keep profitable trades separate from other trades? [solved]

    Questions & Answers
    2
    6
    735
    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.
    • B
      Breeeeen last edited by Breeeeen

      Hi there,

      Desired outcome:
      When a trade (or group of trades) becomes profitable to a certain point, the EA should activate the trailing stop loss (using the trailing start offset setting).
      The trailing stop loss for this trade/trades should be independent of other trade/trades.

      Once the trailing stop loss is active, the EA is to create a new trade in the same direction (buy or sell); this new trade should also be independent of any existing profitable trades.

      Problem to solve for:
      When trades meet the trailing start offset level and begin trailing its stop loss, and the EA then opens a new trade, the trailing stop loss from the existing trades is automatically applied to the new trade even though they have not yet met the trailing start offset point.
      This is likely because I am not using Group IDs.
      When I try using Group IDs (variable which gets incremented whenever a new trade is opened), the EA loses track of the earlier trailing stop losses.

      Question for the community:
      What suggestions are there to have multiple running trades all with separate trailing stop losses?

      If anybody has any helpful suggestions that I could try to implement, that would much appreciated.
      I've included a simple mockup of my setup below.
      Thanks for reading this far!

      (Edited to make it less complicated)
      -Breeeeen

      Breeeeen

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

        @breeeeen Don't know how to do without using groups, you do know the group is just added to the magic number?

        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
        • B
          Breeeeen last edited by

          Thanks @jstap yes I'm aware of this, just reluctant to have so many different magic numbers for tracking reasons.

          If I were to use a group ID, how would you suggest I implement it?
          I tried using variable group IDs and incrementing this number each time a condition is met (i.e. ready to open a new order), but the trailing stop loss losses track of it when that happens since it is now looking at the new Group ID.
          0_1648427574418_31df3551-87da-4d4d-9614-7a7e4c6c8a48-image.png

          Breeeeen

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

            @breeeeen You could add 1 every time a trade is placed, reset when all are closed, use all group numbers in the other blocks like, 1,2,3,4,5,6,7,8,9,10 etc.

            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! 😊

            B 1 Reply Last reply Reply Quote 1
            • B
              Breeeeen @jstap last edited by

              Thanks @jstap, good suggestion. I'll have to do that.
              Now just to figure out how to loop through the various group IDs and apply that to the trailing stop blocks...
              Is there something similar to the "for each position" block for groups IDs (e.g. "for each group" loop)?

              Breeeeen

              1 Reply Last reply Reply Quote 0
              • B
                Breeeeen last edited by

                Managed to figure it out, and in case anyone in the future reads this thread and is stuck at the same place as me, here's what I had to do to loop through all the groups to keep separate trades:

                1. Create a variable (we'll call this variable "Group ID") and use it whenever creating a new buy/sell trade or order. All order-opening related blocks need this Group ID variable. When the conditions for your EA have been met to open a new set of trades, increment this Group ID variable and open the new group with the new Group ID.
                2. Create a second variable (we'll call this "ID checker" variable). The purpose of this variable is to mimic the Group ID variable without interfering or changing the Group ID.
                3. To loop through the various groups you have, use an appropriate block (I used the "For each position") with the group mode set to "All (automated and manually opened)" and connect it to a "Modify variable" block.
                4. In the modify variable block, modify the ID checker variable with the group in the loop.
                5. Connect blocks with actions you wish the EA to perform (trailing stop loss in my case).
                  Picture below depicts points 3, 4 and 5.

                Thanks @jstap for the discussion, talking to someone about this really helps.

                0_1648518486642_3c679108-8c04-4c18-a2d9-56d739170bf2-image.png

                Breeeeen

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

                Online Users

                E
                N
                N
                F
                M
                A
                L
                O
                S

                20
                Online

                146.7k
                Users

                22.4k
                Topics

                122.6k
                Posts

                Powered by NodeBB Forums | Contributors