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.
    • roar
      roar @biztet last edited by

      @biztet Yes, it works. This resets the variable when there is no trades, you might want resetting in some other situtation, but this is one example.

      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

        Thanks a lot @roar .
        Maybe i'll try to separate the reset block for buy&sell using different group&type filter.

        So if i want to make a multipair ea, how can i connect the reset block for each symbol?

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

          @biztet multipair EAs with tracking variables (maxprofit) will get complicated pretty fast. I usually create an array to store the individual maxprofit variables for each pair, and then load from array at the start of "pair cycle" and save into array at the end of "pair cycle".

          I can make an example of what I mean, but I'd suggest optimizing your EA for a single pair first.

          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

            Will do. If my ea works well, i'll consult with you then. Thanks.

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

              @biztet We are contributors of cause. I just have nothing to contribute at the moment.. lol

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

                @AlphaOmega
                Oh, i thought you have already made the million dollar EA since you run away from soehoe. 😄

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

                  Credit to @roar in creating this useful profit checker. And also thanks to @josecortesllobat for bringing this 3years block arrangement to this topic.
                  Today i do FT and the profit checker works perfectly.
                  I think its very good for traders who like to trade full margin. Can secure some profit before its gone when the chart retracing.

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

                    @biztet Hahaha!! Oh man... have not been there since Tanaka left.. maybe I should go make a peep... Yes .... and THANK YOU!!! To all the senior members who helped in this post!!! Respect to you!!

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

                      So unlucky back then i didn't know much about technical and backup strategy. Always thinking about entry, not so focus on taking profit. Maybe Tanaka would have create much better pure coding for our EA. I wish i had learn to analyse indicators first before requesting...

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

                        @josecortesllobat .. I do not really know how to put your code into constants and variables.. Never worked with those stuff and same goes to coding. After lots of back reading I have come up with something but it is not working, and I am afraid I think I am going down the wrong road here
                        .. Please take a look and teach me how to implement what you wrote previously.. greatly appreciated
                        https://fxdreema.com/shared/163e9qHvb
                        0_1598809772346_AO Fancy Strategy.JPG
                        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

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

                          @AlphaOmega

                          As I mentioned earlier, there are several ways to achieve the same result with fxDreema. This is just an option and, of course, the project can be optimized to get a more efficient code. Here it is the long trading side:

                          0_1598856115194_309d9595-0ffe-4a5c-a22f-083ff1be7c8f-image.png

                          https://fxdreema.com/shared/xblYjK0uc

                          0_1598858539003_Profit Math.mq5

                          0_1598857063028_095420a4-f777-4e71-a3b5-88fc8c9593e4-image.png

                          0_1598857159633_91e6def0-2b3d-420d-b53f-af36d1c7457a-image.png

                          0_1598857195997_16163e37-c5dc-4406-b3d7-def597666ac9-image.png

                          Whatever the condition is true to enter at market, that piece of code will open a trade for every new bar with the original take profit value (100 pips in the exxample). When a child trade opens, it calculates the take profit average by getting which is the take profit in pips of the child trade using the parent open price as the reference following this formula structure:

                          TakeProfitAv == (TakeProfitPips + (TPLevel_ChildTrade1 - OpenPrice_ParentTrade) "as pips")) / nTrades

                          After that, the code will modify the child´s TP to TakeProfitAverage.

                          That logic will repeat until you break the loop when your condition to do not enter long at market is met (maybe when start to go short).

                          Keep in mind:

                          • I defined the Pointsize with a number but it can be set with 'Market Properties'. This parameter is used to convert from points to pips or vice versa.

                          • I have used a "Counter: Pass once' (Id=3) block to split the parent trade from the child trades. This block will need to reset at some point along your code. For example, when you break the go long loop. If it is not reset, when the EA starts with a new go long loop, it will not activate the true output of the block.

                          One of the best suggestion that I got from fxDreema support & other forum members is to add blocks that makes me to see if the code is going as I expect:

                          "Draw Arrow" allows me to see that the execution passed through the "modify stops" block
                          "Comment (ugly)" allows me to see the parent trade values
                          "Comment" allows me to see that the calulations are correct

                          Hoping that this example provides you some starting point.

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

                            @josecortesllobat Wow!! I really appreciate the time and effort you took to make this example. Also thank you for your patience as, I am sure other members here also have problems with this variables and constants as the Fxdreema example do not really teach you anything so in fact you are helping the whole Fxdreema community..., So a big THANK YOU and lots of respect to you from my side!
                            I will go through your stuff and give you feedback on my progress.

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

                              WOW!! 8-o
                              Maybe i'll wait for @AlphaOmega to finalize this project.

                              There are EA's that use this Martingale take profit strategy.
                              I also have this kind of EA downloaded online. But i just want to make it my own so that i can modify and test and add few more strategy in it.

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

                                @biztet Lots more work to be done here.. But josecortesllobat has done a great job of putting me on the right track.. If only I really understand this variables and constants. Will let you know when I am finished... look whats it doing firing on only 1 out of 8 cylinders so far
                                0_1598887464431_ec67ab97-9f7b-4de2-a39d-7fb49dd9c360-image.png
                                0_1598887500667_de74a7eb-cc26-4f50-82b7-b06709979910-image.png

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

                                  @josecortesllobat Sorry to bother you again with this... but I am struggling! Would you please give some insight again? You have really and truly explained this strategy in every detail but I am not getting the same results as you.
                                  I understand the many trades comes from "once per bar" block so I started with "no position" block to limit the orders.. This changes the outcome of the "average profit" variable.. I dont know why?
                                  For some reason the counter also do not reset properly because the expert will work With the "for each trade" block to add volume, but then suddenly will put down numerous orders simultaneously. Maybe it is my counter settings? I also played around with a lot of different ways to reset the counter as to not to disturb the working of the "average profit" but cannot come up with a solution. Hence I have to trouble you again for help.
                                  Thank you in advance!
                                  https://fxdreema.com/shared/NVdhiuLcd
                                  0_1599590340351_Stochastic MACD.mq5
                                  0_1599590271896_AAAAAA Profit Math counter.JPG

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

                                    @AlphaOmega

                                    If you add a "No position" block, that will only open the parent trade and none child trades because on the second excution of the code, the "No position" block false output will active and will not pass through the open trade block. You said that you wanted to open a child trade for each new bar once the parent trade was opened.

                                    If there is no child trade, Take profit average is not calculated because it only exists one trade that is the parent one.

                                    If you want to limit the number of trades after opening the parent trade, you will have to use a variable like TradesLimit that will be increased each time that a new trade opens. Then, add a condition block to let pass the project execution while the limit of trades is not reached.

                                    My suggestion is that you should write down your strategy´s rules and then we will try to help you to get what you want. Begin with a basic rule like when this condition is true, do this. When that step is correct, add a new step to the project and check it out.

                                    But remember that the forum members are helping to make the people be more comfortable using fxDreema. They are not EA's coders for free.

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

                                      @josecortesllobat
                                      Thank you for your quick response! I understand about the "No position" block which will not deliver children trades. This is why I put a "for each position" block to create children orders but then I realize that the new "for each position" block is not part of the mathematical structure and will change nothing to my problem of many trades. This made me go back to "once per Bar " block. Also back to the same problem of to many orders.

                                      You have given me a solution to deal with this in your above reply.. ("If you want to limit the number of trades after opening the parent trade, you will have to use a variable like TradesLimit that will be increased each time that a new trade opens. Then, add a condition block to let pass the project execution while the limit of trades is not reached")...Thank you! So now, I will struggle down this road you have pointed.
                                      Concerning the writing of the strategy of my expert... I have done this on a word document. I know Fxdreema is not there for other members to write your expert but rather for oneself to learn how to code your own expert, I have not posted my strategy here because of this reason. This mathematical "profit maths" is small part but also the "heart" I need to make work flawlessly so the bigger mechanicals of my expert can fall into place.
                                      I am not a coder, and also do not know Fxdreema. I learn from all of you unselfish people and the previous examples of the members that struggle just like me.
                                      I am grateful to all of you that put the time and effort in here between your busy schedules.. Thank you.

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

                                        @josecortesllobat Hi Jose, I have decided to give this profit average calculation a miss for now. It is to advance for me to comprehend all the aspects of the mechanics for the average profit and Stop loss. So I will take your suggestion and start a new project with my own blocks and as I go along , ask questions and there by learning at my own pace.
                                        I am wasting too much time in testing and reading up on the forum and so are not moving forward.
                                        I just really want to Thank you for your time and effort you took to help us out in this posts... Thank you.

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

                                          @AlphaOmega Forum members will be glad to help in your growth using fxDreema. We all learnt like that.
                                          Believe me. I was also concerned in sharing some aspects of my strategies in the past but it was needed to move forward. I am not saying that you share all details of your strategy but if you ask for some help, you will need to provide what you are trying to achieve. Keep on trying and learning with fxDreema.

                                          TipsyWisdom AlphaOmega 2 Replies Last reply Reply Quote 0
                                          • TipsyWisdom
                                            TipsyWisdom @josecortesllobat last edited by

                                            @josecortesllobat

                                            hahahha... he said, thanks for not being selfish with your time, but I'm gonna keep being selfish with my awesome ea thought!

                                            @AlphaOmega I used to conflict myself with that too but realizing its no different than the world of business and inventions. Most likely someone else has already thought about it, but unless you share your idea nobody can help you. If you can't share it, nobody else can have the chance to invest in you and your idea.

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

                                            Online Users

                                            B
                                            A
                                            J
                                            D
                                            E

                                            18
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors