fxDreema

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

    How to use 2 volume modes

    Questions & Answers
    3
    23
    7139
    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.
    • M
      miro1360 last edited by

      not sure what exactly this is, but if you need that function from blocks to outside block, place these blocks into some "non executed style" (as false condition block) - it places functions into code and than you can use these functions ...

      https://fxdreema.com/shared/ALrlKBdFd

      0_1495632231443_upload-2470d47b-489e-487f-9616-4880d9d351c1

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

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

        I would like to know how can I modify the code to use the VolumeMode Balance Risk with Fixed Ratio?

        I need you to manage by balance risk, but maximum volume is the result of fixed ratio.

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

          You can't modify the code of system blocks. You can always make custom blocks or MQL4 functions. But maybe you want to make some calculations before using Buy now/Sell now block

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

            I'm not saying the fxDreema block codes, but how to change in mql5 code.

            I need to manage by balance risk, but maximum volume is the result of fixed ratio.

            See:

            
            input double MMPorcento = 20; // MM Porcento
            input double MMVolumeMaximo = 50; // MM Volume Maximo
            input double MMRJUnidade = 0.01; // MM Ryan Jones Unidade
            input double MMRJDelta = 200; // MM Ryan Jones Delta
            
            //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
            // fxDreema block #3 (Buy now) //
            void block3(int _parent_=0)
            {
            	if (block3==false || FXD_BREAK==true) {return;}
            	FXD_CURRENT_FUNCTION_ID=3;
            
            	//////////////////////
            	// Input parameters //
            	//////////////////////
            	
            	string OrdersGroup=""; // Group # (empty=Default)
            	string SYMBOL=CurrentSymbol(); // Market
            	string VolumeMode="balanceRisk, fixedRatio"; // Money management
            	double VolumeSize=0.1; // Lot size
            	double VolumeSizeRisk=50; // Amount of money to risk
            	double VolumeRisk=MMPorcento; // Risk percent
            	double VolumePercent=100; // Volume size
            	double VolumeBlockPercent=3; // Block % of Balance
            	double FixedRatioUnitSize=MMRJUnidade; // Fixed Ratio: Unit size
            	double FixedRatioDelta=MMRJDelta; // Fixed Ratio: Delta parameter
            	double mmMgInitialLots=0.1; // Initial volume
            	double mmMgMultiplyOnLoss=2; // Multiply on loss
            	double mmMgMultiplyOnProfit=1; // Multiply on profit
            	double mmMgAddLotsOnLoss=0; // Add lots on loss
            	double mmMgAddLotsOnProfit=0; // Add lots on profit
            	int mmMgResetOnLoss=0; // Reset after how many losses?
            	int mmMgResetOnProfit=1; // Reset after how many profits?
            	double mm1326InitialLots=0.1; // Initial volume
            	bool mm1326Reverse=false; // Reverse 1-3-2-6?
            	double mmFiboInitialLots=0.1; // Initial volume
            	double mmDalembertInitialLots=0.1; // Initial volume
            	bool mmDalembertReverse=false; // Reverse D'Alembert
            	double mmLabouchereInitialLots=0.1; // Initial volume
            	string mmLabouchereList="1,2,3,4,5,6"; // List of numbers
            	bool mmLabouchereReverse=false; // Reverse Labouchere
            	double mmSeqBaseLots=0.1; // Base volume
            	string mmSeqOnLoss="3,2,6"; // Sequence on loss
            	string mmSeqOnProfit="1"; // Sequence on profit
            	double mmSeqReverse=false; // Reverse system?
            	double VolumeUpperLimit=MMVolumeMaximo; // Volume upper limit
            	string StopLossMode="dynamicLevel"; // Stop-Loss mode
            	double StopLossPips=10; // in pips...
            	double StopLossPercentTP=100; // % of Take-Profit
            	string TakeProfitMode="none"; // Take-Profit mode
            	double TakeProfitPips=10; // in pips...
            	double TakeProfitPercentSL=100; // % of Stop-Loss
            	double l0ca1_Slippage=Slippage; // Slippage
            	string MyComment="Long trade"; // Comment
            
            

            Same procedure with the sell block.

            I tried this but it didn't work. I believe there is something else that needs to be done in mql5 code.

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

              This is the last thing that I can recommend to someone - to edit the end files. As you can see, there are tons of mess in them, thousands of rows of weird stuff. And if you need to do every time... This is bad idea, really.

              What maximum volume? If you want to take this volume, why not just using Ryan Jones. Or if you don't want... then why using it ๐Ÿ˜•

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

                In summary, I need this:

                
                input double MMPorcento = 1; // MM Porcento
                input double MMVolumeMaximo = "fixedRatio"; // MM Volume Maximo
                input double MMRJUnidade = 0.1; // MM Ryan Jones Unidade
                input double MMRJDelta = 200; // MM Ryan Jones Delta
                
                
                
                1 Reply Last reply Reply Quote 0
                • fxDreema
                  fxDreema last edited by

                  I'm from Bulgaria ๐Ÿ˜† And I need to refresh my memories for Ryan Jones ๐Ÿ˜•

                  You want to mix two MM, am I right?

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

                    What I need is for the fixedRatio is the VolumeUpperLimit.

                    
                    input double MMPorcento = 1; // MM Porcento
                    input string MMVolumeMaximo = "fixedRatio"; // MM Volume Maximo
                    input double MMRJUnidade = 0.1; // MM Ryan Jones Unidade
                    input double MMRJDelta = 200; // MM Ryan Jones Delta
                    
                       //////////////////////
                      // Input parameters //
                     ///////////////////////
                    
                    string VolumeMode = "balanceRisk"; // Money management
                    double VolumeRisk = MMPorcento; // Risk percent
                    double FixedRatioUnitSize = MMRJUnidade; // Fixed Ratio: Unit size
                    double FixedRatioDelta = MMRJDelta; // Fixed Ratio: Delta parameter
                    double VolumeUpperLimit = MMVolumeMaximo; // Volume upper limit
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • fxDreema
                      fxDreema last edited by

                      Fixed Ratio == Ryan Jones

                      I don't see how upper volume limit can be a string value, this is the maximum lot size that is numeric (double), like 0.8. And there is an input field for maximum lot size for all MM: http://prntscr.com/7a6epn

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

                        Yes. I know that and I realized in new blocks.

                        But I need to, instead of using a fixed number, use the fixed ratio as the maximum volume.

                        Because with that will have the risk management for balance and SL, but not exceeding the limit of the fixed ratio.

                        How do I do that?

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

                          Just give me an example, how the lot size changes in time?

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

                            Example:

                            Risk% = 1%
                            Upper volume limit = "fixed ratio"
                            RJ Unit = 0.10
                            RJ Delta = 200

                            1% risk in an operation could 0.12 lots.

                            Maximum lot is and 0.10 lots.

                            Let's assume that in a position would give 0.12 lots, but the fixed ratio of the moment is 0.10. So this order opens only 0.10, because the maximum volume based on fixed ratio is 0.10 lot.

                            I made 200 usd profit.

                            RJ Unit rises to 0.20 lots.

                            Suppose in another position would open up 0.15 lots, and the fixed ratio of the moment is 0.20. So this order opens normal in 0.15 lots, because the maximum volume based on fixed ratio is 0.20 lot and not been exceeded.

                            In this way, the risk management will be more conservative and limited to the fixed ratio.

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

                              I think I get your idea now. And the option of Fixed Ration will not be needed, but some calculations - yes. If I remember correctly, the lot size at any given moment can be calculated for Fixed Ratio, because it depends on the profit that is realized.

                              If our start balance is $1000, the initial lot size is 0.1 and we increase the lot size with 0.01 every $100, then can we calculate what will be the lot size when we reach balance of $3050? It will be 0.3 lots, right?

                              0.3 = 0.1 + 0.01 * (3050 - 1000) / 100

                              Well, the result is not exactly 0.3, but it will be rounder to the nearest correct value automatically when you put it into the input field.

                              And if the chosen values are exactly these, there is no need for Ryan Jones, because at $5000 the lot size will be 0.5, at 10,000 it will be 1 lot, everything is linear and the calculation can be simply Balance/10000.

                              So you need Ryan Jones to make thing non-linear. I mean, linear to the profit, but non-linear to the balance. In this case I'm not sure how you will synchronize this MM with another one, which will probably be linear (to the balance).

                              I'm not sure and this is only my feeling, but I think that for the first few profits you will use the lot size calculated from Ryan Jones, and then it will just start to rise too fast to ever reach it with the other MM. Or the opposite.

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

                                __I think I get your idea now. And the option of Fixed Ration will not be needed, but some calculations - yes. If I remember correctly, the lot size at any given moment can be calculated for Fixed Ratio, because it depends on the profit that is realized.[/quote:azsknl2k]
                                That's right! Only the calculations.

                                __If our start balance is $1000, the initial lot size is 0.1 and we increase the lot size with 0.01 every $100, then can we calculate what will be the lot size when we reach balance of $3050? It will be 0.3 lots, right? ...[/quote:azsknl2k]
                                Almost that. It works like this:

                                According to the Fixed Ratio money management method proposed by Ryan Jones, before you can add a lot to an existing number of lots, each of the existing lots shall "win" a certain number of points (which Jones called the "delta"). For example, we have a deposit of 300 dollars and trade with 1 mini lot; the delta of, say, the same 300 dollars would mean that we will increase to 2 mini lots only when we gain (with the 1 mini lot we have) 300 dollars.

                                Similarly, the lots will be increased to 3 only after 2 mini lots will gain the delta of 300 dollars (each). That is, the increase from 2 to 3 mini lots will be possible when we add to the existing 600 dollars another 2 ะกโ€ฆ $300 = $600, i.e. when having $1200; from 3 to 4 mini lots with the deposit of $1200 + ($300 ะกโ€ฆ 3) = $1200 + $900 = $2100, etc. Thus, "the number of contracts is proportional to the amount required to buy a new number of contracts", from where the method derives its name. The decrease in the number of lots follows the same scheme in reverse.

                                We can, of course, run the parameter optimization but let us better have a look at the manual settings. For a pretest, you can use the Opening prices only mode or OHLC on M1.

                                The Money Management System default parameter values are as shown in the table below:

                                PARAMETERS VALUE
                                Start Deposit: 1000
                                Delta: 200
                                Start Lot: 0.1
                                Step Lot: 0.1

                                Formula: x=((1.0+MathSqrt(1+4.0*d))/2)*Step;

                                where: x - the lower boundary of the transition to the next level d = (Profit / delta) * 2.0 Step- a step of the delta, such as 0.1 lots.

                                Source: https://www.mql5.com/en/articles/392#10
                                https://www.mql5.com/en/articles/217

                                Link fo table for sample preview: http://www.tradestation.com/education/l ... ormulas-2#

                                Remembering that is to manage buy and sell together, not individually for each block. As has occurred in testing the management for each block, and not as a risk management for all code, if you know what I mean.

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

                                  I did this MM back then looking at some explanation somewhere and like other MM it was not explained for the world of Forex, so I improvised a little bit. Is it wrong? To be honest, I am really really bad at mathematics, as you can tell.
                                  But anyway, because my idea is to not use this MM from the block and to use some formula instead.

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

                                    Correct! For me, just use the formula of fixedratio in "VolumeUpperLimit" which for me will be great!

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

                                      Hello fxDreema . Waking up this post. Still awaiting answers about How to use the result of Ryan Jones in a variable , so I add this variable in 'Volume Upper limit' , this insides of Buy and Sell Now blocks.

                                      It seems that simple , but still can not do.

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

                                        I don't know, I have no ideas to put MM methods outside Buy/Sell blocks. But if the block that uses RyanJones creates a trade, then you can get the lot size from that trade

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

                                          Okay. So how to get the value of this lot instead of opening an order? I would take this value and add in a variable.

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

                                            Sorry, I have no ideas to put MM methods outside Buy/Sell blocks. In theory you can use the function that is used in Buy/Sell blocks to calculate this value, but I will never recommend to anyone to use the functions I have created. The reason is simple - I will eventually rename/delete them without saying a word. This is the function, use it at your own risk:

                                            DynamicLots("fixedRatio", FixedRatioUnitSize, FixedRatioDelta)
                                            

                                            FixedRatioUnitSize and FixedRatioDelta are to be replaced with your numbers

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

                                            Online Users

                                            A
                                            L
                                            S

                                            11
                                            Online

                                            146.7k
                                            Users

                                            22.4k
                                            Topics

                                            122.6k
                                            Posts

                                            Powered by NodeBB Forums | Contributors