fxDreema

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

    Total profit reduces by x % then close everything.

    Questions & Answers
    5
    80
    31386
    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.
    • timmyhanke
      timmyhanke last edited by

      Im looking for something to effect all of the positions on the terminal when the total profit reduces by lets say 10% then it have to close every position.

      Have tried different approaches using the condition block but havnt found nothing that works .

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

        I would play with some variable:

        Variable maxprofit:
        condition: equity > maxprofit -> modify variable maxprofit to same as current equity

        if equity < maxprofit -> calculate the ratio with formula equity/maxprofit

        if formula result is, lets say lower than 0.9 (thats 10% decrease) -> close positions

        You then should reset the maxprofit to 0, to not mess up calculations in future

        I hope you get what I mean 😄

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        timmyhanke 1 Reply Last reply Reply Quote 0
        • timmyhanke
          timmyhanke @roar last edited by

          @roar

          That was alot to take in , can you set blocks up as you described so i can see what you ment by sharing the link to it ? 🙂

          I dont really know how to use vairables and modify them , and the formula block is something that i dont dear to touch haha 🙂

          Hope you can help me with this one 🙂

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

            Haha, okay, I see 😄

            Wait a moment, I'll build them.

            Variables are some values, like constants, that store numbers

            Formula is just basic calculating, plus minus multiply divide

            I also avoided using variables for years because I didn't want to understand them 😄

            Need small help? Tag me in your post
            Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

            timmyhanke 1 Reply Last reply Reply Quote 0
            • timmyhanke
              timmyhanke @roar last edited by

              @roar

              Thank you so much ! 🙂

              Sometimes you just need someone to show you how its done to be able to play around with it even further , and that someone is you right now 🙂

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

                Here:
                fxdreema.com/shared/6FWqaYX2b

                Need small help? Tag me in your post
                Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

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

                  It's useful to see what the variables are at each moment - the comment block is for that

                  Need small help? Tag me in your post
                  Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                  timmyhanke 1 Reply Last reply Reply Quote 0
                  • timmyhanke
                    timmyhanke @roar last edited by

                    @roar

                    Your variables you are using , maxprofit and Ratio , are they as the picture i uploaded ? 🙂

                    0_1500468042342_ratio.jpg

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

                      Yes, thats how you set them up.
                      You dont usually need to give them any values different than 0, because the ea updates them anyway

                      And the names "maxprofit" and "Ratio" are just pulled from the hat, the code doesn't really care what you name them of course 😄

                      Need small help? Tag me in your post
                      Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                      timmyhanke 1 Reply Last reply Reply Quote 0
                      • timmyhanke
                        timmyhanke @roar last edited by

                        @roar said in Total profit reduces by x % then close everything.:

                        Yes, thats how you set them up.
                        You dont usually need to give them any values different than 0, because the ea updates them anyway

                        And the names "maxprofit" and "Ratio" are just pulled from the hat, the code doesn't really care what you name them of course 😄

                        Its a lot to take in , but thank you for helping me out with this one ! 🙂

                        The backtest of it seems to close everything constantly so i dont think it works quite as it should 😉

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

                          Hmm, did you use the comment block, to view how the variables change?

                          Care to share the project so I can check

                          Need small help? Tag me in your post
                          Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                          timmyhanke 1 Reply Last reply Reply Quote 0
                          • timmyhanke
                            timmyhanke @roar last edited by

                            @roar

                            Changed the strategy a bit so we easier can see what its wrong 🙂

                            https://fxdreema.com/shared/w4x2xemL

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

                              In condition five, I set the Ratio to be lower than 0.9 - check your terminal that the value (inp4_value) really is 0.9. You can also try some different ratio value, maybe that helps.
                              Does it close everything constantly, if you disable the whole variable block tree?

                              Need small help? Tag me in your post
                              Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                              timmyhanke 1 Reply Last reply Reply Quote 0
                              • timmyhanke
                                timmyhanke @roar last edited by

                                @roar

                                I read that the comment function dosnt work in backtest , so maybe thats why ? 🙂
                                does it need the comment block to see and know the value of the maxprofit and ratio variables ?

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

                                  Ah, I use mt5 myself and comment works fine.

                                  No, the comment block is just for you, for debugging

                                  Need small help? Tag me in your post
                                  Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                                  timmyhanke 1 Reply Last reply Reply Quote 0
                                  • timmyhanke
                                    timmyhanke @roar last edited by

                                    @roar

                                    If you set up some trading conditions to the closing part and backtest it , do you also get that it closes the trades constantly ? 🙂

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

                                      Aaa, I found the problem!

                                      Need small help? Tag me in your post
                                      Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

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

                                        After closing the trades, you need to reset the maxprofit to 0 - otherwise the logic works only one time.
                                        Check how I did the resetting in https://fxdreema.com/shared/6FWqaYX2b
                                        Block #5

                                        Need small help? Tag me in your post
                                        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

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

                                          This method doesn't actually precisely answer to your question, because it works with account equity, not profit. But with some changes, the method can be applied to the profit, loss or anything you want

                                          Need small help? Tag me in your post
                                          Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

                                          timmyhanke 1 Reply Last reply Reply Quote 0
                                          • timmyhanke
                                            timmyhanke @roar last edited by

                                            @roar

                                            the block 5 changes dosnt show , but i assume that you write 0 in the maxprofit adjust field ? 🙂
                                            0_1500474579741_test.jpg

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

                                            Online Users

                                            P
                                            B
                                            S
                                            S
                                            T
                                            F
                                            I
                                            S
                                            S
                                            G
                                            I

                                            26
                                            Online

                                            146.6k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors