Tester in new build 604 doesn't work correct - page 4

 

Created this simple EA to test on 509 and 604, both on MQ demo account 444 same server, backtest over the same dates.

  • EA makes alternate buy sell buy sell trades
  • fixed SL/TP. Lot sizing based on account balance. Source codes below.
  • 509 compiled on 509 and tested on 509
  • 600 compiled on 604 and tested on 604
Strategy Tester Report
Test EA 509
MetaQuotes-New MT4 Test (Build 509)

SymbolEURUSD (Euro vs US Dollar)
Period1 Hour (H1) 2013.10.14 06:00 - 2013.12.30 23:00 (2013.01.01 - 2013.12.31)
ModelEvery tick (the most precise method based on all available least timeframes)
Bars in test1384Ticks modelled1448514Modelling quality46.42%
Mismatched charts errors0
Initial deposit10000.00
Total net profit-1199.25Gross profit20200.90Gross loss-21400.15
Profit factor0.94Expected payoff-8.75
Absolute drawdown2515.20Maximal drawdown3725.52 (33.23%)Relative drawdown33.23% (3725.52)
Total trades137Short positions (won %)68 (41.18%)Long positions (won %)69 (44.93%)
Profit trades (% of total)59 (43.07%)Loss trades (% of total)78 (56.93%)
Largestprofit trade394.33loss trade-337.74
Averageprofit trade342.39loss trade-274.36
Maximumconsecutive wins (profit in money)4 (1494.97)consecutive losses (loss in money)12 (-3337.77)
Maximalconsecutive profit (count of wins)1494.97 (4)consecutive loss (count of losses)-3337.77 (12)
Averageconsecutive wins2consecutive losses2
Averageconsecutive wins2consecutive losses2

 
Test EA 600+
MetaQuotes-New MT4 Test (Build 604)

SymbolEURUSD (Euro vs US Dollar)
Period1 Hour (H1) 2013.10.14 06:00 - 2013.12.30 23:00 (2013.01.01 - 2013.12.31)
ModelEvery tick (the most precise method based on all available least timeframes)
Bars in test1384Ticks modelled1459801Modelling quality46.42%
Mismatched charts errors0
Initial deposit10000.00SpreadCurrent (6)
Total net profit-1985.08Gross profit19147.44Gross loss-21132.52
Profit factor0.91Expected payoff-14.81
Absolute drawdown2677.75Maximal drawdown4021.28 (35.45%)Relative drawdown35.45% (4021.28)
Total trades134Short positions (won %)67 (40.30%)Long positions (won %)67 (44.78%)
Profit trades (% of total)57 (42.54%)Loss trades (% of total)77 (57.46%)
Largestprofit trade394.33loss trade-337.74
Averageprofit trade335.92loss trade-274.45
Maximumconsecutive wins (profit in money)4 (1494.97)consecutive losses (loss in money)12 (-3336.50)
Maximalconsecutive profit (count of wins)1494.97 (4)consecutive loss (count of losses)-3336.50 (12)
Averageconsecutive wins2consecutive losses2
 
//========================================================================
//|                                                      Test EA 509.mq4 |
//|                                                  Copyright 2014, SDC |
//|                                        https://www.mql5.com/en/users/sdc |
//========================================================================
#property copyright "Copyright 2014, SDC"
#property link      "https://www.mql5.com/en/users/sdc"

//========================================================================
  int start()
//========================================================================
 {
//----
  static int ticket;
//----
  if(OrderSelect(ticket,SELECT_BY_TICKET))
  {if(OrderCloseTime()<=0) //-------------------- last order is still open
   {return(0);
   }else //------------------------------------------ last order is closed
   {if(OrderType()==0) ticket = maketrade(1);
    if(OrderType()==1) ticket = maketrade(0);
  }}else //-------------------------------------- cant find previous order
  {ticket = maketrade(0);
  }
//----
  return(0);
 }
//========================================================================
  int maketrade(int op)
//========================================================================
 {
  int errcnt=0;
  int mn = 777;
  int ticket=0;
  double lot=lots();
  double price=0;
  double sl=30;
  double tp=40;
//----
  if(lot<=0)return(0);
  if(Digits == 5 || Digits ==3)
  {sl*=10;
   tp*=10;
  }
  if(op == 0)
  {price = Ask;
   tp = Bid + tp*Point;
   sl = Bid - sl*Point;
  }
  if(op == 1)
  {price = Bid;
   tp = Ask - tp*Point;
   sl = Ask + sl*Point; 
  }
  while(ticket < 1)
  {ticket=OrderSend(Symbol(),op,lot,price,0,sl,tp,"",mn,0,Gold);
   if(ticket>0)return(ticket);
   else errcnt++;
   if(errcnt>2)return(0); //-------------------------------- 3 tries abort
   if(errors(GetLastError())==1) continue; //------------------- try again
   else return(-1);
  }
//----
  return(0);
 }
//========================================================================
  double lots()                                  //---- generic lot sizing
//========================================================================
 {
  string pair    = Symbol();
  double free    = AccountFreeMargin();
  double maxlot  = MarketInfo(pair,MODE_MAXLOT);
  double minlot  = MarketInfo(pair,MODE_MINLOT);
  double onelot  = MarketInfo(pair,MODE_MARGINREQUIRED);
  double lot     = AccountBalance()/10000;
  double newlot  = 0;
  double step    = MarketInfo(pair,MODE_LOTSTEP);
//----
  if(lot*onelot < free) newlot=MathFloor(lot/step)*step;
  else newlot=MathFloor(free/onelot/step)*step;
  if(newlot > maxlot) newlot = maxlot;
  if(newlot < minlot) newlot = minlot;
  if(newlot*onelot < free) return(newlot);
//----   
  return(0);
 }
//========================================================================
  int errors(int error)                     //---- generic errror handling 
//========================================================================
 {
  Print("Test EA 509 Error: ",error);
  if(error==0) return(0);
  switch(error)
  {
//recoverable error
   case  129:  RefreshRates();               return(1); //---- wrong price    
   case  135:  RefreshRates();               return(1); //-- price changed
   case  136:  while(RefreshRates()==false)
               Sleep(1);                     return(1); //------ no quotes
   case  138:  RefreshRates();               return(1); //-------- requote     
   case  146:  Sleep(500);
               RefreshRates();               return(1); //---- system busy
//logical error
   case  130:                                return(2); //-- invalid stops
   case 4108:                                return(2); //- invalid ticket
//critical error
   case   2:                                 return(3); //--- common error
   case   5:                                 return(3); //---- version old
   case  64:                                 return(3); //---- acc blocked
   case 133:                                 return(3); //----- prohibited
   default :                                 return(3); //---- other error
  }
//----
  return(0);
 }
//========================================================================
 
//========================================================================
//|                                                     Test EA 600+.mq4 |
//|                                                  Copyright 2014, SDC |
//|                                        https://www.mql5.com/en/users/sdc |
//========================================================================
#property copyright "Copyright 2014, SDC"
#property link      "https://www.mql5.com/en/users/sdc"
#property version   "1.00"
#property strict
//========================================================================
  void OnTick()
//========================================================================
 {
//----
  static int ticket;
//----
  if(OrderSelect(ticket,SELECT_BY_TICKET))
  {if(OrderCloseTime()<=0) //-------------------- last order is still open
   {return;
   }else //------------------------------------------ last order is closed
   {if(OrderType()==0) ticket = maketrade(1);
    if(OrderType()==1) ticket = maketrade(0);
  }}else //-------------------------------------- cant find previous order
  {ticket = maketrade(0);
  }
//----
  return;
 }
//========================================================================
  int maketrade(int op)
//========================================================================
 {
  int errcnt=0;
  int mn = 777;
  int ticket=0;
  double lot=lots();
  double price=0;
  double sl=30;
  double tp=40;
//----
  if(lot<=0)return(0);
  if(Digits == 5 || Digits ==3)
  {sl*=10;
   tp*=10;
  }
  if(op == 0)
  {price = Ask;
   tp = Bid + tp*Point;
   sl = Bid - sl*Point;
  }
  if(op == 1)
  {price = Bid;
   tp = Ask - tp*Point;
   sl = Ask + sl*Point; 
  }
  while(ticket < 1)
  {ticket=OrderSend(Symbol(),op,lot,price,0,sl,tp,"",mn,0,Gold);
   if(ticket>0)return(ticket);
   else errcnt++;
   if(errcnt>2)return(0); //-------------------------------- 3 tries abort
   if(errors(GetLastError())==1) continue; //------------------- try again
   else return(-1);
  }
//----
  return(0);
 }
//========================================================================
  double lots()                                  //---- generic lot sizing
//========================================================================
 {
  string pair    = Symbol();
  double free    = AccountFreeMargin();
  double maxlot  = MarketInfo(pair,MODE_MAXLOT);
  double minlot  = MarketInfo(pair,MODE_MINLOT);
  double onelot  = MarketInfo(pair,MODE_MARGINREQUIRED);
  double lot     = AccountBalance()/10000;
  double newlot  = 0;
  double step    = MarketInfo(pair,MODE_LOTSTEP);
//----
  if(lot*onelot < free) newlot=MathFloor(lot/step)*step;
  else newlot=MathFloor(free/onelot/step)*step;
  if(newlot > maxlot) newlot = maxlot;
  if(newlot < minlot) newlot = minlot;
  if(newlot*onelot < free) return(newlot);
//----   
  return(0);
 }
//========================================================================
  int errors(int error)                     //---- generic errror handling 
//========================================================================
 {
  Print("Test EA 600+ Error: ",error);
  if(error==0) return(0);
  switch(error)
  {
//recoverable error
   case  129:  RefreshRates();               return(1); //---- wrong price    
   case  135:  RefreshRates();               return(1); //-- price changed
   case  136:  while(RefreshRates()==false)
               Sleep(1);                     return(1); //------ no quotes
   case  138:  RefreshRates();               return(1); //-------- requote     
   case  146:  Sleep(500);
               RefreshRates();               return(1); //---- system busy
//logical error
   case  130:                                return(2); //-- invalid stops
   case 4108:                                return(2); //- invalid ticket
//critical error
   case   2:                                 return(3); //--- common error
   case   5:                                 return(3); //---- version old
   case  64:                                 return(3); //---- acc blocked
   case 133:                                 return(3); //----- prohibited
   default :                                 return(3); //---- other error
  }
//----
  return(0);
 }
//========================================================================
 

509 Graph:

604 Graph:

 

They appear to run identical tests except for the last quarter I think that is because I was running a beta test version on the same server (albiet a differnt demo account) Probably live feed data which may have gaps in it is interfering with the test. I am going to delete the chart history and let both terminals download the same chart history then redo the test.

Edit: I might have known that would be a trial in itself. Nice that MQ has 1 minute chart data going back to 1974 but I didnt want all of it !! Its like you can have none at all or so much that you need half of silcon valley in your PC !! my terminal is now running 700mb RAM *rollseyes*

 
SDC:

They appear to run identical tests except for the last quarter I think that is because I was running a beta test version on the same server (albiet a differnt demo account) Probably live feed data which may have gaps in it is interfering with the test. I am going to delete the chart history and let both terminals download the same chart history then redo the test.

Edit: I might have known that would be a trial in itself. Nice that MQ has 1 minute chart data going back to 1974 but I didnt want all of it !! Its like you can have none at all or so much that you need half of silcon valley in your PC !! my terminal is now running 700mb RAM *rollseyes*


hello, can you try M15 and M1 tests for this. did you converted code from old mq4 to new one? can you please try with an old complex mq4 EA, with conversion to new mq4.

including other data types, like datetime etc. including internal and custom indicators.. i could not see any indicators used in this code..

604's possible problem is, some number precisions lost, for indicators and other numbers.

i need to develop a number test method to compare exact values of variables, for two environments...

 

Probably not the root cause of your issue, but in 60x do you need to include a ResetLastError() somewhere? (1st command inside while loop?)

 
cbalta:


hello, can you try M15 and M1 tests for this. did you converted code from old mq4 to new one? can you please try with an old complex mq4 EA, with conversion to new mq4.

including other data types, like datetime etc. including internal and custom indicators.. i could not see any indicators used in this code..

604's possible problem is, some number precisions lost, for indicators and other numbers.

i need to develop a number test method to compare exact values of variables, for two environments...


I used the same source code I posted, I compiled the 509 test code on the 509 Metaeditor, I compiled the 600 source code on the 604 metaeditor, the only differences between the two are the new one uses void OnTick() the old one uses start()

I did not use any indicators because I wanted this to be a basic test with as few unknowns as possible we can modify the EA's to use indicators and other trade criteria if you want to widen the test parameters.

 
ydrol:

Probably not the root cause of your issue, but in 60x do you need to include a ResetLastError() somewhere? (1st command inside while loop?)

I'm not sure do I need to ? I'll look it up, the EA's ran the tests without errors so I didnt get to see how the GetLastError() performed in the new terminal. My heavy RAM usage (maxed out at over 1 GB) was due to decades of 1 minute chart data that was downloaded from metaquotes demo server when I hit the download button in history center, I had to delete some of it.