fxDreema

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

    I need a loop, but don't know which one

    Questions & Answers
    5
    19
    4243
    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.
    • l'andorrà
      l'andorrà last edited by

      I'm creating my first hedging EA and 85% of it works fine. I just need a final loop to complete it but I simply cannot find the way to do it. General wisdom in this forum will be appreciated. This how it works:

      1. A general trend is identified so that only buys or sells will be opened, never both at the same time.
      2. The first trade of the new trend belongs to group 1.
      3. All consecutive trades after the first one belong to group 2. There can be more than one at the same time, as well as trades from both groups simultaneously.
      4. When price moves in loss in any of them, a hedging trade is open at a fixed distance from its 'parent's' open price.
      5. When price reaches again that fixed distance back, the hedging trade is immediately closed. If price is in loss again and hits that fixed distance again, a new hedging trade is open.

      This means that we can find a situation like this:

      a) One group 1 trade and its hedging counterpart.
      b) One group 2 trade and its hedging counterpart.
      c) A second group 2 trade with no hedging counterpart.

      I don't know how many group 2 trades can be open at the same time, but all of them must open a hedging counterpart as described above. And this is where some help would be appreciated. In my current project I can do it for a single group 1 trade and another single group 2 trade. I know I can create new groups to identify more 'group 2' trades, but it is hugely increasing the number on blocks required and that doesn't fix the problem because maybe there will be another group 2 trade to be open that will not be caught by the EA.

      I guess a loop should be the solution, but they are not my field of expertise. Is there a way to create a loop identifying:

      a) How many trades of groups 1 and 2 are open?
      b) How many of them have a hedging counterpart open so that no more counterparts are open for each of them?

      Any help will be much appreciated.

      (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

      (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

      (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

      T 1 Reply Last reply Reply Quote 0
      • T
        trader.philipps @l'andorrà last edited by

        @l-andorrà If you want to identify a certain trade and its hedge trade maybe use a global variable and store the ticket number at it?!? delete the variable if the hedge is closed. Hence you would at least per each trade know, which one is hedged already. Just a thought. Alternatively you may put this information in the comment, but that would give some logic viewable by your broker.

        I like to share my knowledge, but expect the others to contribute as well.

        1 Reply Last reply Reply Quote 0
        • l'andorrà
          l'andorrà last edited by

          But i can't see that is different from I'm doing now. I will need as many global variables as open trades and I will never know how many of them will be needed to cover all of them now.

          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

          T 1 Reply Last reply Reply Quote 0
          • T
            trader.philipps @l'andorrà last edited by trader.philipps

            @l-andorrà Variables can have a name and a value. You add 1 variable with name of the ticket to the first trade with no value (or a dummy one). When the hedge trade for that first trade is opened, you'd set the value of the variable with the ticket number of the hedge trade. Once the hedge trade is closed, you'd delete the value of the hedge (or set a dummy one). Once the first trade is closed, you'd delete (don't know if that is possible) the variable or set it to a value that you consider to be closed.
            Check this or for working with global variables.

            I think you need something that "survives" a MT4 restart or you'd come up with a better solution and maybe close all trades when EA is loaded. But in that case you wouldn't be able to change a setting of EA without forcing it to close all trades.

            I like to share my knowledge, but expect the others to contribute as well.

            l'andorrà 1 Reply Last reply Reply Quote 0
            • M
              miro1360 last edited by miro1360

              almost any automated hedge system will be very complex and you may not avoid a custom code (even looping) ... it may take several days (or months, or years, based on experience and complexity) to create such a workable hedge system, and you will learn that the hedge system is not a good way to go, it's just postponing an unavoidable crash 😄
              I think there is no active automated hedged system that would offer benefits, 1/3 of them are just an overcomplicated SL/TP, the next 1/3 is martingale, and the rest will be a random confusion 😄

              Between trading and gambling is a very small gap, be careful.

              l'andorrà L 2 Replies Last reply Reply Quote 2
              • l'andorrà
                l'andorrà @trader.philipps last edited by

                @trader-philipps Interesting. Should this 'dummy' initial value be a zero? I'm not sure I understand what you mean by 'no value'.

                BTW, thank you for your help. 🙂

                (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                1 Reply Last reply Reply Quote 0
                • l'andorrà
                  l'andorrà @miro1360 last edited by

                  @miro1360 Oh, God! If miro is saying this I'm doomed! 😞 Apparently I got into a minefield without me noticing it...

                  Thank you for your help also.

                  (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                  (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                  (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                  T 1 Reply Last reply Reply Quote 0
                  • L
                    luisjunior1224 @miro1360 last edited by

                    @miro1360 In your experience, which bots work best in the future?

                    Luis Martinez

                    1 Reply Last reply Reply Quote 0
                    • T
                      trader.philipps @l'andorrà last edited by

                      @l-andorrà Well, in theory a hedge seems to be a good way, but on every hedge trade you'll loose a bit (spread, swap, commissions, etc). Furthermore you will find yourself babysitting your account rather than enjoy the trading. Believe me, I've been through this including a hedge EA and manual trading. You'll notice that market sleeps less than you need sleep.

                      So to come to @luisjunior1224 question:

                      1. Manage your risk.
                      2. Accept losses as it is part of trading and not a personal failure
                      3. Find a strategy that fits to your mentality
                      4. Have a positive risk reward ratio
                      5. Don't take every opportunity, but the ones with the highest probability
                      6. Try to eliminate technical impacts such as connection loss to broker, Metatrader crashes, gaps over weekends, etc.

                      And most of all: Trade and don't gamble! Learn the basics before risking your hard owned money!

                      I like to share my knowledge, but expect the others to contribute as well.

                      1 Reply Last reply Reply Quote 0
                      • l'andorrà
                        l'andorrà last edited by

                        Thank you for your good advice. 😉

                        (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                        (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                        (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                        1 Reply Last reply Reply Quote 0
                        • P
                          paragorundu last edited by

                          Hello @l-andorrà ,

                          I am working on something that really has similar parts as what you are trying to do.

                          I have tried for weeks, ended up desperate some days but finally I have something to proceed.

                          Since I am very tired and sleepless, please for give me if I get your question wrong and reply something that's not you are looking for.

                          You can create a variable (to use in related fields of no trade, if trade, buy & sell blocks) and set it to 1, then buy/sell trade following +group number with some blocks (modify variable or custom mql code), reset it back when all trades closed.

                          I was able to accomplish;
                          -to create one group and add all the additional trades in it
                          -to create tens/hundreds of groups by increasing group number by 1 just using a few blocks (for a simple condition strategy)

                          and manage them separately.

                          I now do not have time to explain in detail (using screenshots etc.) but please be aware that can be accomplished.

                          I will be happy to provide as much info as I can when I have time but for now you can start working with this idea.

                          I hope it's useful and works for you.

                          Regards.

                          l'andorrà 1 Reply Last reply Reply Quote 0
                          • l'andorrà
                            l'andorrà @paragorundu last edited by

                            @paragorundu said in I need a loop, but don't know which one:

                            Hello @l-andorrà ,

                            I am working on something that really has similar parts as what you are trying to do.

                            I now do not have time to explain in detail (using screenshots etc.) but please be aware that can be accomplished.

                            I will be happy to provide as much info as I can when I have time but for now you can start working with this idea.

                            I hope it's useful and works for you.

                            Regards.

                            Sounds like a very interesting idea, my friend. Please don't hesitate to share it when you have propely slept. 😉 Thank you.

                            (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                            (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                            (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                            1 Reply Last reply Reply Quote 0
                            • P
                              paragorundu last edited by

                              Hi @l-andorrà ,

                              Here is what I did;

                              I run a loop for a group of conditions which try to match an indicator's parameters with price level and create buy/low trades accordingly.

                              Loop runs n times (10 in my setup) and changes some inputs for conditions every time it runs. After running n times, condition at the most top level resets variables to initial values and loop restarts.

                              If first condition is met a buy/sell order is created with group number 1.
                              If second condition is met a buy/sel lorder is created with group number 2.
                              .
                              .
                              etc.

                              Group numbers are derived from values of variables used in indicator. So for example, if parameter 1 is matched to create a buy order, it is created with 'Group Number 1' and continiues to run loop till end. When values of variables are reseted and loop tests same parameter values, it also checks if there is a trade with same group number. If parameter 1 matches again and there is buy trade running with group number 1, no other buy trade will be created for parameter 1.

                              On the other hand, sell trade will be created if it matches the conditions for parameter 1.

                              For some reasons I can only share related part of the stategy.

                              0_1577538020285_VariableLoop.png

                              I believe you can have as many groups as your balance & margin allows with this logic. You can manage the groups any way you want.

                              You can also add to same group with 'If trade' block by using the same variable in Group # area if needed.

                              One important thing is that, calculations and conditions need to run in an order. If you do not arrange the running order you will get different group number calculations and will end with undesirable results.

                              If you need more detail, I will try my best to do so.

                              I hope it helps.

                              Regards.

                              1 Reply Last reply Reply Quote 0
                              • l'andorrà
                                l'andorrà last edited by

                                My dearest paragorundu,

                                Let me say that this is probably one of the best Xmas presents I've been given in the last years! I think this is exactly what I'm looking for. I have to study it, though.

                                Can I take the liberty of taking advantage of your generosity and ask for a copy of those blocks and variables, please? I know I don't need to see the whole project. Just these wonderful blocks in the loop.

                                Please accept my <insert number here> (Loop) thanks. 😉

                                (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                1 Reply Last reply Reply Quote 0
                                • P
                                  paragorundu last edited by

                                  Hello @l-andorrà ,

                                  I am really happy that this was what you were looking for 🙂

                                  I also want to thank you because you are trying to help on most of the topics. I already now this from my posts but I saw many of your replies while I was doing search on the forum lol.

                                  Of course I have to thank @miro1360 , @trader-philipps and other great guys for their contributions to topics. I really learnt a lot from their ideas.

                                  Here is the link to the part of conditions that I have shared via screenshot.

                                  https://fxdreema.com/shared/TO7KfGmne

                                  There should be a better way to do this, if so I will be appreciated for comments.

                                  Please let me know if you need any other details.

                                  Regards.

                                  1 Reply Last reply Reply Quote 1
                                  • l'andorrà
                                    l'andorrà last edited by

                                    Believe me, miro, roar and trader.philipps are the real code breakers here, not me. 😉

                                    Once more, thank you four help. I will study it in detail but as far as I tested on my own this is what I'm looking for. 🙂

                                    (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                    (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                    (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

                                    P 1 Reply Last reply Reply Quote 0
                                    • P
                                      paragorundu @l'andorrà last edited by

                                      @l-andorrà thay's great! Hope you get good results 🙂

                                      Cheers!

                                      1 Reply Last reply Reply Quote 0
                                      • P
                                        paragorundu last edited by

                                        Hi @l-andorrà ,
                                        I have an update here:

                                        I had some issues with this setup. I got undesirable results in some cases with this loop. I removed the loop block and just used condition & modify variable blocks to run a loop which provided accurate results.

                                        0_1581060411039_condiloop.JPG

                                        Initial value for 'incLoop' variable is set to 0 which is increased by one in custom mql code block until it is equal to LoopNumber (which is 10 in my case) and loop restarted.

                                        I don't know if it you could use previous setup but if you are still working on your project you may try this loop instead.

                                        Regards.

                                        1 Reply Last reply Reply Quote 0
                                        • l'andorrà
                                          l'andorrà last edited by

                                          Thank you for your update info. I already fixed the problem, but you new setting is very interesting. I will take it into cosideration in the future.

                                          (English) I will try to help everyone in these fxDreema forums. But if you want to learn how to use the platform in depth or more quickly, I can help you with my introductory fxDreema course in English at https://www.theandorraninvestor.eu.

                                          (Català) Miraré d’ajudar tothom en aquests fòrums d’fxDreema. Tanmateix, si vols aprendre a fer servir la plataforma amb més profunditat o més de pressa, t’hi puc ajudar amb el meu curs d’introducció a fxDeema en català a https://www.theandorraninvestor.eu/ca.

                                          (Español) Intentaré ayudar a todo el mundo en estos foros de fxDreema. Sin embargo, si quieres aprender a usar la plataforma en profundidad o más deprisa, te puedo ayudar con mi curso de introducción a fxDreema en español en https://www.theandorraninvestor.eu/es.

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

                                          Online Users

                                          K
                                          E
                                          D
                                          E
                                          M
                                          H
                                          C
                                          I
                                          I

                                          26
                                          Online

                                          146.6k
                                          Users

                                          22.4k
                                          Topics

                                          122.6k
                                          Posts

                                          Powered by NodeBB Forums | Contributors