fxDreema

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

    Attach Manually Opened Trade To EA

    Questions & Answers
    2
    13
    4294
    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.
    • T
      Trader3487 last edited by

      Is there a way to assign a group number to manual trades so that correct group in ea will handle them?

      In general, I assume if the group mode in the "for each trade" block was set to "manually opened", the ea would pick up trades that I opened myself?

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        Yes, this is the idea. Otherwise manuals have magic number 0, but the magic number is controlled here: http://prntscr.com/3s148c - it is the sum of both numbers that I focused with red.

        1 Reply Last reply Reply Quote 0
        • T
          Trader3487 last edited by

          this works as long as "allow live trading" is checked in expert advisor properties > common (F7 from chart). The problem with keeping it checked is that it will also automatically open trades but I want it to only manage the orders that I manually open but also have the option to let the ea open trades automatically. In other words, is there a way to build in a manual/automatic switch that if I decide I want it to run automatically it can do that or if I want to open manual trades and only have the ea manage them, it can do that? Maybe this is too advanced a feature, I guess could have two versions of the ea attached to two different charts if necessary.

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            What about the "AutoTrading" button?
            For the EA to work with only manual trades, set Magic Start Number in the Project Options to 0... I think it will work. Or "MagicStart" input parameter that comes with every EA. Both are the same thing.

            1 Reply Last reply Reply Quote 0
            • T
              Trader3487 last edited by

              so far so good - looks like that works. That's exactly what I was looking for, now I can just switch the magic number back if I want the ea to resume trading automatically. Do you think the magic number has to be switched back to the same number or can it be set to any number other than zero?

              1 Reply Last reply Reply Quote 0
              • fxDreema
                fxDreema last edited by

                Magic number is just another property of all orders, like stop-loss, take profit, symbol, type, ticket number, lots... but it's nowhere visible. You know that in MT4 you can run multiple EAs at once, but in the same time all orders are in one single pool, visually. So, the magic number is the property to allow every EA to recognize orders placed by it and to not touch others. Of course, if you have two EAs, one for EURUSD and another for USDJPY, then you can recognize orders by symbol name and no magic number is needed. But when two or more EAs work with EURUSD we must have something else.
                And Magic number stays with the order on the server, so if you restart MT4 or even go in different MT4, that number will be there and the same EA will be able to continue working with it's own orders placed before.

                Well, this is just a number after all, and I extended it in fxDreema to this number called "Group", so in the same EA we can place orders with different magic numbers. There is input parameter MagicStart, and the real magic number that order will take is MagicStart+Group. That Group number is 0 by default, so the real magic number that will be taken by default equals to MagicStart.

                This is when you place order, for example with "Buy now". MagicStart is considered.
                When searching for order, for example with "No trade is running", I added some more options, look at the "Group mode" parameter.

                1 Reply Last reply Reply Quote 0
                • T
                  Trader3487 last edited by

                  ok, thanks for the explanation - some of the information was new to me. I get it, I'm just wondering about the following scenario:

                  let's say I load the ea that has some blocks where group mode is set to "manually opened" and others set to a specific group number. I go to properties (F7) > inputs. MagicStart is set to 9490 and when the AutoTrading button is enabled, the ea opens orders automatically. Now, let's say I go back to inputs and change MagicStart to 0. Now the ea does not open orders by itself anymore but will still manage the manually opened orders because of the trailing stop that is set to "manually opened". Now, I decide I want the ea to open trades again automatically. Do I go back to inputs and change the magic start number back to a number? Does it have to be 9490?

                  1 Reply Last reply Reply Quote 0
                  • fxDreema
                    fxDreema last edited by

                    Uuuummm, I think it will be better if everything is in the EA, so there will be no need to change input parameters all the time. Or two separate EAs, if one is not enough.

                    1 Reply Last reply Reply Quote 0
                    • T
                      Trader3487 last edited by

                      I thought setting magic number to 0 was working but it is still opening trades automatically.

                      1 Reply Last reply Reply Quote 0
                      • fxDreema
                        fxDreema last edited by

                        Again, Magic number is just a property for each order (trade ot whatever you call it). This property is given to it when it is created, and then it can't be changed. It is then used to filter that order out of all the others, because they are all in the same house. It's almost like filtering trades by type - Buy or Sell - that type is almost as magic number.

                        In Buy now and Sell now, which are the blocks to create new trades, you give some magic number, which depends on MagicStart.

                        Magic Number = MagicStart + Group number.

                        Because normally MagicStart is some 4-digits number, the magic number of trades created in the EA is something like 1234. Or 1235. Or 1236... if Group number is ised.

                        Then, when you want to load and check trades, blocks like "No trade is running" are used. These blocks can see all the trades, no matter of their magic number, but there are filter options to choose which one to see. You want only Buys - filter then by type. You want only EURUSD - filter them by market. You want to filter them by magic number - go to Group settings. And there are some settings for that. By default it is set to the default MagicStart (plus 0), so only EAs made by this EA wilbe filtered. Additionaly in "Manual" option only those with magic number 0 should be filtered. Or in the "All" option - all, no matter of any magic number, really all that are available at the moment.

                        1 Reply Last reply Reply Quote 0
                        • T
                          Trader3487 last edited by

                          sorry, I got them mixed up. I actually meant MagicStart. Even when I set MagicStart to 0 from mt4 > expert properties > inputs , the ea still opens trades automatically.

                          1 Reply Last reply Reply Quote 0
                          • fxDreema
                            fxDreema last edited by

                            Executing "Buy now" creates new Buy trade immediately. Executing "Sell now" creates new Sell trade immediately. No matter what the magic number is. When to execute "Buy now" or "Sell now" - this is the big question.

                            This: https://fxdreema.com/shared/XX8SjCU2e has MagicStart = 0 and opens new trade only when there is no manual trade ot trade created with this EA. I tested it, it works for me
                            This: https://fxdreema.com/shared/oPb1HOM4b opens trade with MagicStart = 1234, but checks Manual trades before that. In result it opens trade on each tick until I create manual trade (with magic 0). Again, it works for me.

                            1 Reply Last reply Reply Quote 0
                            • T
                              Trader3487 last edited by

                              I see the difference 🙂

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

                              Online Users

                              G
                              K
                              P
                              M
                              M

                              20
                              Online

                              146.7k
                              Users

                              22.4k
                              Topics

                              122.6k
                              Posts

                              Powered by NodeBB Forums | Contributors