fxDreema

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

    Make EA close all trades when balance is below 10%

    Questions & Answers
    3
    11
    3207
    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.
    • Fabien S
      Fabien S last edited by

      Close all when achieves (10)% profits That's mean the EA will read the balance and set the TP target to close depending on the percentage from settings Same for loses, set close all trades on 10% loses on balance.

      i have made this ea but it doesnt work
      shared/C6qakVyLb

      can someone spot my mistake? Maybe i have to put it in On trade?

      1 Reply Last reply Reply Quote 0
      • Fabien S
        Fabien S last edited by

        0_1565178492116_Bildschirmfoto 2019-08-07 um 15.46.59.png

        1 Reply Last reply Reply Quote 0
        • Fabien S
          Fabien S last edited by

          ![alt text](0_1565200418751_Bildschirmfoto 2019-08-07 um 21.53.07.png image url)

          How do i get -10% of balance

          Fabien S 2 Replies Last reply Reply Quote 0
          • Fabien S
            Fabien S @Fabien S last edited by

            @fabien-s nop doesnt work this way
            also doesnt seem to work

            1 Reply Last reply Reply Quote 0
            • Fabien S
              Fabien S @Fabien S last edited by

              @fabien-s the equals doesnt work however >= works, very strange

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

                Could you please share the project itself? Screenshot are partially explanatory but more info is required to find the problem.

                (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
                • Fabien S
                  Fabien S last edited by

                  https://fxdreema.com/shared/aoAeID5Kb

                  thats the link, i have rtades open that i want all to be closed when 10% profit or 10% loss on balance. Right now i got it working with >= but not ==. I also wanted to make the adjust a input parameter but somehow when i put % it rejects it hmm

                  Fabien S 1 Reply Last reply Reply Quote 0
                  • Fabien S
                    Fabien S @Fabien S last edited by

                    @fabien-s the problem with >= is that its not 10% but a bit more

                    1 Reply Last reply Reply Quote 0
                    • Fabien S
                      Fabien S last edited by

                      ![alt text](0_1565205856803_Bildschirmfoto 2019-08-07 um 23.23.54.png image url)0_1565205861994_Bildschirmfoto 2019-08-07 um 23.23.43.png

                      I also wonder if this is the right way to do it..

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

                        No, no, no... don't add one of these "inp..." things in Constants. And don't use == when you compare prices or money. Use anything else, but not ==.

                        10%, but 10% of what? Balance is the amount of money you had the last time you had 0 opened orders. Close all opened orders and the Balance is equal to Equity now. Do you really want to compare Balance with Equity?

                        10% sounds to me like such a small value that you should not reach it so quickly. If Equity can be less than 10% of the Balance, this EA is not good from the start.

                        If you mean 10% from some initial value... for example you can deposit 1000 dollars and you want to close everything when you reach 100 dollars, even if this is 6 months in the future... then the problem is that the EA can't really know what is that initial value that you had in mind half a year ago. There are ways to remember values for a while, but in this case maybe it's better to hard code the value in the EA

                        Otherwise you can try something like this:
                        0_1565217848199_58cb372c-6814-4d42-8f80-0f905b52717d-image.png
                        Remember that here Equity and Balance are those global values that are result from all trades.

                        Or this one:
                        0_1565219159496_dc51f238-e9de-4002-b386-8ba2900de4e3-image.png
                        Here this block calculates the profit from the running orders only, it doesn't care about closed orders. AccountBalance() gives you the balance. This is function from MQL4. There is also AccountEquity() and other functions.
                        So, let's say the we have initial deposit of 1000 dollars. This is the Balance. Then we start losing and the block calculates that out profit is negative. The block would pass if the profit is < 20, because -1 * 1000 * (0.02) is 20. I made my tests and it was easier for me to close the trades when the loss was below 98% of the balance, that's why I used 98 there.
                        Note that the values used there have .0 at the end. Apparently, if you do it like this (100 - 98 / 100), the calculation will fail, because in MQL4 these numbers are integers and the final result is also integer. The result can't be 0.02, it will be 0. To get the result as floating point number, I wrote these numbers as floating numbers.

                        Fabien S 1 Reply Last reply Reply Quote 1
                        • Fabien S
                          Fabien S @fxDreema last edited by

                          @fxdreema Thanks a lot for your answer; I really appreciate the help

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

                          Online Users

                          A
                          A
                          Y
                          H
                          B
                          K
                          S

                          16
                          Online

                          146.7k
                          Users

                          22.4k
                          Topics

                          122.6k
                          Posts

                          Powered by NodeBB Forums | Contributors