fxDreema

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

    Help wanted, please!

    Questions & Answers
    5
    40
    18970
    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.
    • isp00rt
      isp00rt last edited by

      Hi FxDreema,

      I created a new EA designed to close all my open trades once a preset pip level is reached. What I want to do is manually opening several trades at differents charts simultaneously. Then my EA will be operating from a different chart and adding/substracting pips from my previous closed trades as well as my current open ones. In essence, what I want is harvesting a specific pips' target per day (25, 35, 50, etc.). This target is included as a constant manually.

      I tried this: https://fxdreema.com/shared/lv4vkjdob

      But it doesn't work. Every time I put it on a chart, pips are counted before ANY trade is open!! 😮 I simply can't see why it's not working. Could you please help me?

      Thank you very much on advance.

      FXFun 1 Reply Last reply Reply Quote 0
      • FXFun
        FXFun @isp00rt last edited by FXFun

        @isp00rt Hi
        FIRST of all, you say you want to Close all trades, after you accumulated a certain amount of Pips from all open trades. Right?

        IF SO, your condition to close trades, is something TOTALLY DIFFERENT from what you say you want. Your condition to close is a MA Cross!?

        Also, you NULL the variables at the MA cross as well, which could happen at any time, when you don't want that.

        I don't think you need to null the variables, cause if there are non open trades, MQL should calculate that your variable for Open Pips is 0.

        Your condition to Close should probably be something like: CurrentTotalOpenPips >= MyTargetPips

        SECOND, you have 2 loops + 2 modify blocks that are identical. I would delete one of loops (to simplify & make the EA faster), and add the 2 formula blocks last in the one loop.

        I don't understand all your variables that aren't defined, but the formula you use could also be wrong.

        I believe if you start correcting the above first, you should be much closer to the solution you want, or even solve it totally I guess. You need to start there anyway I believe. Let's know how you progress.

        Have Fun! 🙂

        Life is FUN - when you have control over it. Take control over FX & Have FUN all the Time! :-)

        isp00rt 1 Reply Last reply Reply Quote 0
        • isp00rt
          isp00rt @FXFun last edited by

          @fxfun said in Help wanted, please!:

          @isp00rt Hi
          FIRST of all, you say you want to Close all trades, after you accumulated a certain amount of Pips from all open trades. Right?

          Yes, that's exactly what I want.

          IF SO, your condition to close trades, is something TOTALLY DIFFERENT from what you say you want. Your condition to close is a MA Cross!?

          No. My condition to close is having at least as many pips as I specified as a target. That includes all previous closed trades that were a loss.

          Also, you NULL the variables at the MA cross as well, which could happen at any time, when you don't want that.

          No, no. There's no MA anywhere. This EA will be operating on a chart and I will manually operate other charts. It will control all my open and closed trades so that the final amount of pips accumulated is at least the one I specified as a target.

          I don't think you need to null the variables, cause if there are non open trades, MQL should calculate that your variable for Open Pips is 0.

          Interesting. I didn't consider that.

          Your condition to Close should probably be something like: CurrentTotalOpenPips >= MyTargetPips

          That would count all my current open trades, but I need another variable to count my closed ones (wins and loses).

          SECOND, you have 2 loops + 2 modify blocks that are identical. I would delete one of loops (to simplify & make the EA faster), and add the 2 formula blocks last in the one loop.

          You're right. My fault! Good idea. 😉

          I don't understand all your variables that aren't defined, but the formula you use could also be wrong.

          I need 4 variables. ProfitOpen counts the total amount of pips from current open trades. ProfitClose does the same for all my closed trades. ProfitAll is the sum of both previous ones (this one must be at least as big as the target). ProfitTemp is the way to update ProfitOpen and ProfitClose.

          I believe if you start correcting the above first, you should be much closer to the solution you want, or even solve it totally I guess. You need to start there anyway I believe. Let's know how you progress.

          Have Fun! 🙂

          Thank you very much for your help. I did your suggested correction, but it still doesn't work. 😞 https://fxdreema.com/shared/hAA1LhAmc

          Maybe my problem is with variables. I assume that ProfitClose will just sum up all closed trades but I'm not sure how to do that. How can a variable distinguish when a trade is open or closed? Maybe this is why it is failing. What do you think?

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

            Hi again,
            I redesigned the whole EA and I think I got closer to my goal. You can find it here:
            https://fxdreema.com/shared/KCY4ZHjgd. I erased one variable (ProfitTemp) and I now work with just 3 of them and 1 single constant.

            Now my problem is that variables ProfitOpen (the sum of pips of all open trades) and ProfitClose (same for all closed trades) show exactly the same number no matter what. Additionally, open orders are not detected at all. Apparently the EA is not detecting anu order at all, open or close.

            Could you please give me some help?

            1 Reply Last reply Reply Quote 0
            • M
              miro1360 last edited by miro1360

              For each trade blocks are working as "loop" for trade conditions which you specified ...
              .... maybe this can working, I have not tested it ...
              https://fxdreema.com/shared/YSMm3lMKd
              .... I added here one condition for situation, when sum of closed trades reached Targed, and when you open new trade, it will be immediately closed because profit sum of all opened trades (with small profit) + history profit still be higher as targed .... so after "close all" is EA terminated ... and you need "check" or something manually, if profit of history trades pass your next trades opening, and you can specify unix timestamp value (it is time in seconds from year 1970 to now), you can use this converter to get right timestamp from specific date:
              http://www.onlineconversion.com/unix_time.htm
              ... ... of course you can somehow automate it all with more condition blocks and another logic/variables/conversions, but that is for loooonger testing and failing and testing and ... 🙂

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

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

                Hi Miro1360,

                Thank you very much for your suggestion, but it doesn't work. No pips are counted (open or close). Are you sure that "loop" option is correct here? As FxFun said, you put it exactly the same on both open/closed "For each trade" blocks and I'm not sure this is how it should work :(.

                Any other suggestion?

                1 Reply Last reply Reply Quote 0
                • M
                  miro1360 last edited by miro1360

                  you know what I dont like? when I investigate time to help somebody, when I am 99% sure that I am doing it right :D, somebody tell me it is not working - and than I test it because I trust somebody that somewhere is mistake because he proved it .... and after my test I see, that it is working 😄 ... (I added simple buttons to test it in tester) ... and it is working exactly as I expected and described it in first post .... pips are counting, I just must proved myself ...

                  0_1509014170644_0b709360-1705-4812-afb8-ad0d83105776-image.png

                  0_1509014179737_dae19dc9-f51d-48e9-b9e7-131ae26ffa87-image.png

                  0_1509014187112_3ffc0796-8034-49d5-80b9-6d90d94a5ec2-image.png

                  0_1509014195048_de3e1953-146b-48fe-b6d4-a00b56d3eaf1-image.png

                  0_1509014204967_94976abb-2266-4b52-8790-8c58e1a67893-image.png

                  0_1509014214719_9f7a8432-a820-4d5a-a274-02fb4005b7d8-image.png

                  0_1509014223326_3b02b03a-3557-43d5-9737-317a487eabce-image.png

                  yes here with profitOpen:
                  0_1509014548228_84ed4221-7292-4600-9b62-490c00029b0e-image.png

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

                  1 Reply Last reply Reply Quote 0
                  • M
                    miro1360 last edited by miro1360

                    is your MagicNumber set to 0? because 0 is for manually opened trades .. or both EA must have the same magic number if you open trades with one EA and want close it with another EA ...

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

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

                      Hi Miro 1360,

                      Please accept my apoligizes if my words sounded rude. My intention was NOT to underappreciate your time and effort to solve my problem. On the contrary, I have to admit that I am impressed by your knowledge of FxDreema. Once again, let me express my gratitude for your help.

                      However, I'm afraid there must be something different between your MT4 platform and mine. Could you please confirm you are testing this?: https://fxdreema.com/shared/YSMm3lMKd

                      I try it at my MT4 platform and this is what I get:

                      alt text

                      As you can see, the EA is correctly running and three orders are currently open (all of them manually), and yes, the Magic Number is 0. Nonetheless, no pips are counted. All three variables are showing the same 0 result. Maybe I am doing something wrong, but honestly I don't know what :(.

                      1 Reply Last reply Reply Quote 0
                      • M
                        miro1360 last edited by

                        if magic is 0, it must normally working ... when it is not, try different broker or new installation of metatrader (or installation of newest version) ... 😉
                        here is buttons version (the same, only added buttons) https://fxdreema.com/shared/SBxzCtIpb

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

                        isp00rt 1 Reply Last reply Reply Quote 0
                        • C
                          cucushanji82 last edited by

                          try https://fxdreema.com/shared/qncZoz4Kb
                          set money target ext parameter, close single or multiple trades if target money reached

                          isp00rt 1 Reply Last reply Reply Quote 0
                          • isp00rt
                            isp00rt @miro1360 last edited by

                            @miro1360 said in Help wanted, please!:

                            if magic is 0, it must normally working ... when it is not, try different broker or new installation of metatrader (or installation of newest version) ... 😉
                            here is buttons version (the same, only added buttons) https://fxdreema.com/shared/SBxzCtIpb

                            Ok. I found the problem. Your code works fine if I set the "Close Time (UNIX)" value at 0.0. Otherwise it doesn't count pips. Probably I'm not inserting the time variable correctly. What values should be understood by the EA?

                            Thank you in advance.

                            1 Reply Last reply Reply Quote 1
                            • isp00rt
                              isp00rt @cucushanji82 last edited by

                              @cucushanji82 said in Help wanted, please!:

                              try https://fxdreema.com/shared/qncZoz4Kb
                              set money target ext parameter, close single or multiple trades if target money reached

                              Interesting, but I need to specify my target as pips, not as profit. I don't see that option elegible at your "Bucket" block. Do you know how could I substitute it, please?

                              Thank you in advance.

                              @cucushanji82 said in Help wanted, please!:

                              try https://fxdreema.com/shared/qncZoz4Kb
                              set money target ext parameter, close single or multiple trades if target money reached

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

                                Hi again miro1360,

                                I finally decided to remove the time variable from the EA. I tried it and it works perfectly! 😉
                                Thank you very much for your help. This forum and people like you are simply priceless.

                                1 Reply Last reply Reply Quote 1
                                • M
                                  miro1360 last edited by

                                  interesting problem with that 0.0 ... my metatrader give it automatically as 0.0 ... as input type it can be int instead of double (as I gave) but it should converts automatically ... but good that you have what you want 😉

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

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

                                    Hi again miro1360,

                                    I found an unexpected problem. Today I began to use your code and my other EAs in other charts and I'm afraid it's not calculating all variables correctly. Let me show you what's happening. Open trades are counted correctly (in pips):

                                    alt text

                                    But I don't know why closed trades are all counted as a positive result, including the negative ones:

                                    alt text

                                    This means that ProfitAll variable is also wrong. As you can see at the image, ProfitAll counts correctly ProfitOpen and ProfitClose. The problem is that ProfitClose considers all closed trades as positive, no matter they aren't.

                                    I didn't test your code for a long time so far, this is why I didn't see this, sorry :(.

                                    1 Reply Last reply Reply Quote 0
                                    • M
                                      miro1360 last edited by miro1360

                                      what can be wrong ... because for me it is working for sure, I tested it also in demo (not only in tester) ... are you sure that your blocks are in right order, or have you not forget for something?

                                      0_1509469872131_eb582951-7504-4a21-8465-4a73816d5599-image.png

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

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

                                        Once again, accept my apologizes. I know what's the problem now. The MT4 platform MUST NOT have any closed trade BEFORE running the EA. If ALL trades of the day are opened AFTER the EA is running, everything works fine. For some reason the EA does not understand negative closed trades existing before it is running. Now I'm changing my MT4 settings so that only the trades closed today are shown at the display so that they will be immediately erased tomorrow.

                                        What could I possibly forget for the EA not to count them correctly?

                                        1 Reply Last reply Reply Quote 0
                                        • M
                                          miro1360 last edited by

                                          look on my trades when they were closed and than look when I posted my post 😄 .. you can see, that EA recognize trades which were opened before EA was running 😄 .... be sure, that Magic ID of previous closed trades is right ...

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

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

                                            I will test it more carefully and will be back here if any other problem is found. Thank you very much. 😉

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

                                            Online Users

                                            S
                                            T
                                            A
                                            Y
                                            H
                                            B
                                            K

                                            13
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors