fxDreema

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

    Profit Math

    Questions & Answers
    7
    85
    24847
    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.
    • B
      biztet last edited by

      Hello experts. Sorry, cannot think of the correct topic.
      I need help to do this, my idea in securing profit.

      For example.

      0_1598110801286_Screenshot_20200818_153425_net.metaquotes.metatrader4.jpg

      Lets say the current profit is now 2200. And it can still go up&down.

      So i want to make like this, the ea will record the highest total current profit achieved. As the picture show its 2200.
      When the number decrease more than certain % from the highest current profit, e.g 60%, the ea will close all trade, and we secure the 40% profit.
      Also to set the minimum current profit, lets say 1000. The rule applies when the current profit reach minimum 1000.
      And so if highest is 1000, it will close at 400. Highest 2200 will close at 880. If the profit increase, the ea will record the new high to count the 60% decrement.

      Hope its easy to understand and can guide with the block arrangement.

      Thanks a lot.

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

        Use trailing stop, it has a "% of profit" option

        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
        • B
          biztet last edited by biztet

          So this is the same solution that i couldn't understand clearly before?
          Hahaha... Thanks a lot @roar. Hopefully my understanding is correct now. And so i should use the group trailing for this, right?

          But how can i set the minimum profit to start the trailing?

          1 Reply Last reply Reply Quote 0
          • R
            ramisignals last edited by

            if you put stop loss you need to put same value in trailing group

            1 Reply Last reply Reply Quote 0
            • B
              biztet last edited by

              Hi @ramisignals . Could you please help me with this one?

              0_1598137296013_Screenshot_20200823_065935.jpg

              How can i do like what you suggest?

              1 Reply Last reply Reply Quote 0
              • R
                ramisignals last edited by

                could you send SL you are using

                1 Reply Last reply Reply Quote 0
                • J
                  josecortesllobat last edited by

                  https://fxdreema.com/forum/topic/4858/total-profit-reduces-by-x-then-close-everything

                  AlphaOmega 1 Reply Last reply Reply Quote 0
                  • AlphaOmega
                    AlphaOmega @josecortesllobat last edited by AlphaOmega

                    @josecortesllobat Could you help me also with my TP average please? I want to code so that each child trade that is placed, make the take profit go to the average of of all trades running. This is what roar suggested but I can not get it to work correctly and also is based on random lot sizes, which it should not be.
                    0_1598185891976_AO - Test Average TP.mq5
                    The following picture is how I want it to work
                    0_1598185928693_AO Fancy Strategy.JPG

                    I would really appreciate your help .. Thank you in advance!!

                    1 Reply Last reply Reply Quote 0
                    • B
                      biztet last edited by

                      Hi @AlphaOmega , i use to see this in martingale version EA. But i also don't know how to set the TP.

                      @ramisignals , sorry i'm just thinking of the idea, but haven't set any specific SL yet.

                      @josecortesllobat , seems it has been done before, but when it comes to variables, hohohohoho.. 😢
                      *hoping someone can set for me to give it a try...

                      AlphaOmega 1 Reply Last reply Reply Quote 0
                      • AlphaOmega
                        AlphaOmega @biztet last edited by

                        Yes... It is similar bur there is also a twist in the money management because martin only can be dangerous... So i am hoping on someone to help me with this... The senior members has the answer.... Please consider helping here guys because I have no clue how to go about this.... Thank you in advance!

                        1 Reply Last reply Reply Quote 0
                        • J
                          josecortesllobat last edited by josecortesllobat

                          Hi @biztet

                          @roar built that amazing profit checker code. I can say that works greatfully and it was built using variables.

                          0_1598249148403_dfee3e67-4854-46d2-84e7-faab3af743cd-image.png

                          "the ea will record the highest total current profit achieved. As the picture show its 2200."

                          'maxprofit' == 0 (reset it as per you need)
                          If 'Equity' > 'maxprofit' -> 'maxprofit' == "Equity'

                          "When the number decrease more than certain % from the highest current profit, e.g 60%, the ea will close all trade, and we secure the 40% profit0."

                          If 'Equity' <= 'maxprofit' -> calculate 'Ratio' as 'Equity' / 'maxprofit'
                          If 'Ratio' < MinRatio (0.6 for you) -> Close positions

                          "Also to set the minimum current profit, lets say 1000. The rule applies when the current profit reach minimum 1000."

                          You just need to add condition blocks somewhere within your code to activate the 'profit checker'. This might be an approach:

                          Define -> bool ProfitCheckerON false (reset it as per your need)
                          Condition block -> If 'Equity' > 1000 -> ProfitCheckerON == true
                          Condition block -> If ProfitCheckerON == true -> true output is activated and the profit checker starts to work

                          Hi @AlphaOmega

                          Regarding to your question: TP average. Probably there is a much efficient way to code it because fxDreema allows to reach the same goal with multiple ways. I assume that each child trade has a fixed TP that probably will be the same as for the parent trade. Let´s call it 'TakeProfitPips'. Using your example,

                          nTrades == 0 (reset it as per your need)
                          TakeProfitPips == 100

                          OpenPrice_ParentTrade == 1.00000
                          nTrades == 1

                          TPLevel_ParentTrade == OpenPrice_ParentTrade + TakeProfitPips (as price fraction) = 1.00000 + 0.00100 = 1.00100

                          OpenPrice_ChildTrade1 == 1.00010
                          nTrades == 2

                          TPLevel_ChildTrade1 == OpenPrice_ChildTrade1 + TakeProfitPips (as price fraction) = 1.00010 + 0.00100 = 1.00110

                          TakeProfitAv == (TakeProfitPips + (TPLevel_ChildTrade1 - OpenPrice_ParentTrade) "as pips")) / nTrades
                          = (100 + (1.00110 - 1.00000) "as pips" ) / 2
                          = (100 + 110) / 2 = 210 / 2 = 105

                          Modify ChildTrade1 TP to 105 pips -> TP_ChildTrade == 105

                          OpenPrice_ChildTrade2 == 1.00020
                          nTrades == 3

                          TPLevel_ChildTrade3 == OpenPrice_ChildTrade3 + TakeProfitPips (as price fraction) = 1.00020 + 0.00100 = 1.00120

                          TakeProfitAv == (TakeProfitPips + [(TP_ChildTrade ) + (TPLevel_ChildTrade2 - OpenPrice_ParentTrade) "as pips"]) / nTrades
                          = (100 + [(105) + (1.000120 - 1.00000) "as pips" ] )/ 3
                          = (100 + [(105) + (120)] )/ 3 = 325 / 3 = 108.3

                          Modify ChildTrade2 TP to 108 pips -> TP_ChildTrade == 108

                          .... and so on

                          Not sure if that is what you are looking for strictily but might be a starting point.

                          AlphaOmega 2 Replies Last reply Reply Quote 0
                          • B
                            biztet last edited by

                            Nice work @josecortesllobat .
                            Yes i did read most of the last 2-3years discussion on the topic. What i'm looking for is there.
                            But....i can only read.... :'((

                            1 Reply Last reply Reply Quote 0
                            • AlphaOmega
                              AlphaOmega @josecortesllobat last edited by

                              @josecortesllobat .. Wow!! thank you so much for your reply... I will firstly try to understand what you have written because I have no coding skills as such and also secondly have never work with this variables/constants... Much appreciate that you took the time and trouble to help me here... Thank you!

                              1 Reply Last reply Reply Quote 0
                              • B
                                biztet last edited by

                                Yeah, and after that you can help by sharing with me, right @AlphaOmega ? 🙂

                                AlphaOmega 1 Reply Last reply Reply Quote 0
                                • B
                                  biztet last edited by biztet

                                  Hi @roar , @josecortesllobat
                                  Is this correct?

                                  0_1598316222833_Untitled-1-01.jpg

                                  How can i add to make is start when the current profit reached certain amount, like $100/$500/$1000?

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    biztet last edited by

                                    Is this correct? Only need these 2 variables, right?

                                    0_1598318429004_Untitled-2-01.jpg

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

                                      @biztet you must put the condition "current profit is above maxprofit" before updating your maxprofit variable, otherwise "maxprofit" is actually just the current profit.

                                      To set $100/$500/$1000 treshold, simply use "check profit"
                                      0_1598351131463_78bf6a67-cd78-4e03-ae23-56119675b170-image.png

                                      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
                                      • B
                                        biztet last edited by biztet

                                        Thanks @roar .
                                        Btw, the EA is not running, got error i assume.
                                        I just copy whats yours and create the variable maxprofit & ratio.

                                        Also pls guide how to reset the maxprofit value, if needed.

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

                                          @biztet for example:
                                          0_1598352226330_ce312546-6097-48dd-839a-416db8268de5-image.png

                                          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
                                          • B
                                            biztet last edited by

                                            Is it enough if i just add like that ib my ea?

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

                                            Online Users

                                            T
                                            J
                                            B
                                            A
                                            T
                                            M
                                            E

                                            20
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors