MT4 Relative Drawdown
Results 1 to 6 of 6

Thread: MT4 Relative Drawdown

  1. #1
    Can somebody explain to me how relative drawdown is calculated on mt4 detailed performance? I know maximal but not how comparative is calculated.

  2. #2
    This post is split into 3 components.
    Part 1 describes how MT4 records Relative Drawdown, which isn't well known.
    Part 2 will present my code to calculate Relative Drawdown against Balance only before a trade, which I inherently loe much more useful.
    Part 3 reveals the mql4 code for calculating and displaying this Relative Drawdown against Balance.

    --------------------------------------------------------------------------

    How MT4 calculates Relative Drawdown

    Relative Drawdown in MT4's report is calculated as a portion of the difference of the historical equity high and equity low, against the equity high. E.g. Account balance at the start is $100. A trade is opened and then enter floating profit of $10. This produces the equity high $100 $10 = $110. The trade subsequently goes into negative territory of $20. This produces the equity low $100-$20 = $80. Relative Drawdown(MT4) is calculated as: ($110-$80)/$110 * 100 = 27.27%
    Proceed to http://articles.mql4.com/127 to your true code involved with the report generation.

    --------------------------------------------------------------------------

    Relative Drawdown against Balance

    I calculate a drawdown as the sum going Beneath the Balance(in the Beginning of a trade) rather than this Equity high. Rationale is that when a trade goes into profit but isn't shut, this floating profit never'belonged' to the trader, or algorithm, and shouldn't be construed as banked profit.

    I shall illue with a breakeven trade for both ways of calculation for Relative Drawdown:
    Account balance at the start is $100. A trade is opened and then enter floating profit of $10. This produces the equity high $100 $10 = $110. A breakeven is put at the entrance price. The price retraces and exits at breakeven.
    For MT4's Relative Drawdown, it's:
    ($110-$100)/$110 * 100 = 9.09%For Relative Drawdown based on pre-trade Balance, it's:
    ($100-$100)/$100 * 100 = 0%With MT4's calculation, even though your Equity never fell below your starting Balance, your Relative Drawdown is 9.09%. However, with Relative Drawdown calculated contrary to deception, it's 0%. Which makes for more meaningful interpretation. (NB. Technically the moment you start a trade, the spread already incurs a drawdown on the Balance, but I leave it outside from the explanation here in order to simplify matters )

    Illuing previous instance with Relative Drawdown calculated from Balance:
    Account Balance in the start is $100. A trade is opened and then goes to profit of $10. This produces the equity high $100 $10 = $110. The trade subsequently goes into negative territory of $20. This produces the equity low $100-$20 = $80. Relative Drawdown(Balance) is calculated as: ($100-$80)/$100 * 100 = 20.00%
    We see today for an account with a remaining Balance of $80 in the starting Balance of $100, it's more meaningful to say that it's suffered a 20 percent drawdown, rather than a 27.27percent drawdown.

    An extreme example to illue the meaningful use of MT4's Relative Drawdown calculation:
    Account Balance in the start is $100. A trade is opened and then enter floating profit of $500. This produces the equity high $100 $500 = $600. The trade subsequently goes into negative territory of $20. This produces the equity low $100-$20 = $80. Relative Drawdown(MT4) is calculated as: ($600-$80)/$600 * 100 = 86.67%
    Even though the account is only 20% below the starting Balance, MT4 reports the Relative Drawdown as 86.67 percent. Not so meaningful.

    --------------------------------------------------------------------------

    MQL4 Code:
    Currently the technical piece, to exhibit this outstanding information, enter your code:

    Inserted Code int begin () //your code; MaxDD(); MaxDDM(); Comment(MaxDD(), \n, MaxDDM()); //for showing on your screen (adapt to your comments as you see fit) return(0);
    Insert this purpose into your EA to exhibit as a string for printing or commenting:
    Maximum Relative Drawdown percent against on Balance Corresponding Maximum Relative Drawdown as an amount on your Deposit Currency (not so important) Time when this Maximum Relative Drawdown occurred (useful for analysis)
    Inserted Code string MaxDD() //Maximum drawdown information; displayed as DD%(corresponding DD$),time of incident series DC = AccountCurrency(); //Deposit Currency if(DC == JPY) int DCdeci = 3; else DCdeci = two; //to exhibit Deposit Currency JPY and non-JPY with correct decimal places static dual mddp = 0, dd = 0; inactive datetime y = 0, m = 0, d = 0; dual ddp = (NetDC() NetSwap() NetComm()) / AccountBalance() * 100; //drawdown percentage if (ddp lt; mddp) //if current DD%(ddp) is more than previous logged DD%(mddp) mddp = ddp; //log current DDpercent as newest maximum DDpercent dd = NetDC() NetSwap() NetComm(); //log DD$ in the moment that DD% is best y = TimeYear(TimeCurrent()); m = TimeMonth(TimeCurrent()); d = TimeDay(TimeCurrent()); return(StringConenate(MaxDD:, DoubleToStr(-mddp,2),%, (, DoubleToStr(-dd,DCdeci),, DC, ), , y,. , m, . , d));
    This purpose is just like the above but with margin consumed added in. I find this is important as it gives a real picture of just how close you have come to a margin call. Particularly for accounts with low leverage.

    Inserted Code string MaxDDM() //Maximum drawdown data such as margin used string DC = AccountCurrency(); if(DC == JPY)int DCdeci = 3; else DCdeci = two; static dual mddp = 0, dd = 0; static datetime y = 0, m = 0, d = 0; dual ddp = (NetDC() NetSwap() NetComm() - AccountMargin()) / AccountBalance() * 100; if(ddp lt; mddp) mddp = ddp; dd = NetDC() NetSwap() NetComm() - AccountMargin(); y = TimeYear(TimeCurrent()); m = TimeMonth(TimeCurrent()); d = TimeDay(TimeCurrent()); return(StringConenate(MaxDDM:, DoubleToStr(-mddp,2),%, (, DoubleToStr(-dd,DCdeci),, DC, ), , y,. , m, . , d));
    Insert this into your deinit() to print it on deinitialisation. Useful when conducting non-visual backtests.

    Inserted Code int deinit() Print(MaxDD()); //to print to Journal after Strategy Tester ends or EA disabled Print(MaxDDM()); return(0);
    The outcome should be that you find this on your display:


    And this on your journal:

  3. #3
    How to calculate maximum drawdown?

  4. #4

  5. #5
    Hi and thanks for sharing RaidenWorks, however, works NetDC(), NetSwap(), NetComm() are missing. Could you please post this works?

    Regards

    Benton

  6. #6
    Relative drawdown is a ratio between the maximal drawdown and also the value of the corresponding local maximum of the equity. This coefficient shows losses, in percents of equity, seasoned with an Expert Advisor; Maximal drawdown is the greatest difference between one of those regional maximums and the following minimum of the equity; Total drawdown is the difference between the initial deposit and the smallest value of the equity. In other words, this parameter shows how much beneath the initial deposit amount the Player's equity has ever fallen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners more information