Can someone explain to me how relative drawdown is calculated on mt4 detailed performance? I understand maximal but not how relative is calculated.
MT4 Indicator - Time to Candle Close & Spread (absolute&relative) 21 replies
MT4 does not show intraday drawdown 1 reply
MT4 Processor Drawdown 11 replies
MT4 Strategy tester include margin calc in drawdown? 0 replies
unrealised drawdown script for mt4 3 replies
($110-$100)/$110 * 100 = 9.09%
For Relative Drawdown based on pre-trade Balance, it is:($100-$100)/$100 * 100 = 0%
With MT4's calculation, even though your Equity never dropped below your starting Balance, your Relative Drawdown is 9.09%. But with Relative Drawdown calculated against Balance, it is 0%. Which makes for more meaningful interpretation. (NB. technically the moment you open a trade, the spread already incurs a drawdown on the Balance, but I leave it out in the explanation here to simplify things)int start(){ //your code; MaxDD(); MaxDDM(); Comment(MaxDD(), "\n", MaxDDM()); //for displaying on your screen (adapt to your own comments as you see fit) return(0); }
string MaxDD(){ //Maximum drawdown data; displayed as "DD%(corresponding DD$),time of occurrence" string DC = AccountCurrency(); //Deposit Currency if(DC == "JPY") int DCdeci = 3; else DCdeci = 2; //to display Deposit Currency JPY and non-JPY with correct decimal places static double mddp = 0, dd = 0; static datetime y = 0, m = 0, d = 0; double ddp = (NetDC() + NetSwap() + NetComm()) / AccountBalance() * 100; //drawdown percent if (ddp < mddp){ //if current DD%(ddp) is more than previous logged DD%(mddp) mddp = ddp; //log current DD% as latest maximum DD% dd = NetDC() + NetSwap() + NetComm(); //log DD$ at the instant that DD% is greatest y = TimeYear(TimeCurrent()); m = TimeMonth(TimeCurrent()); d = TimeDay(TimeCurrent()); } return(StringConcatenate("MaxDD: ", DoubleToStr(-mddp,2), "%", "(", DoubleToStr(-dd,DCdeci), " ", DC, "), ", y, ".", m, ".", d)); }
string MaxDDM(){ //Maximum drawdown data including margin used string DC = AccountCurrency(); if(DC == "JPY")int DCdeci = 3; else DCdeci = 2; static double mddp = 0, dd = 0; static datetime y = 0, m = 0, d = 0; double ddp = (NetDC() + NetSwap() + NetComm() - AccountMargin()) / AccountBalance() * 100; if(ddp < mddp){ mddp = ddp; dd = NetDC() + NetSwap() + NetComm() - AccountMargin(); y = TimeYear(TimeCurrent()); m = TimeMonth(TimeCurrent()); d = TimeDay(TimeCurrent()); } return(StringConcatenate("MaxDDM: ", DoubleToStr(-mddp,2), "%", "(", DoubleToStr(-dd,DCdeci), " ", DC, "), ", y, ".", m, ".", d)); }
int deinit(){ Print(MaxDD()); //to print to Journal after Strategy Tester ends or EA disabled Print(MaxDDM()); return(0); }
double NetDC(){ //Net profit in deposit currency double ndc=0; for(int i=OrdersTotal()-1;i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)ndc+=OrderProfit(); } return(ndc); } double NetSwap(){ //Net swap in deposit currency double ns=0; for(int i=OrdersTotal()-1;i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)ns+=OrderSwap(); } return(ns); } double NetComm(){ //Net commission in deposit currency double nc=0; for(int i=OrdersTotal()-1;i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol()&&OrderMagicNumber()==Magic)nc+=OrderCommission(); } return(nc); }