Download MetaTrader 5

Automatic Validation problem

To add comments, please log in or register
Somsri Sarkar
3689
Somsri Sarkar  

Hi

I have a mql5 code which get failed at automatic validation process. Same code & logic works for mql4 with no problem. But in case mql5 is showing Tester too long time error in automatic validation page. In general, this indicator takes 2500msc to compile in mt5 as its a 4000+ line of codes which I can not decrease. Any option in such case to validate ?

Thank you

Regards

Alain Verleyen
Moderator
33618
Alain Verleyen  
Somsri Sarkar:

Hi

I have a mql5 code which get failed at automatic validation process. Same code & logic works for mql4 with no problem. But in case mql5 is showing Tester too long time error in automatic validation page. In general, this indicator takes 2500msc to compile in mt5 as its a 4000+ line of codes which I can not decrease. Any option in such case to validate ?

Thank you

Regards

Optimize your code.
Somsri Sarkar
3689
Somsri Sarkar  
Alain Verleyen:
Optimize your code.

Is there any limit on the lines of coding? 

What is the standard compilation time for automatic validation approval?

Update: I decreased the line of to 2400, now compilation time is 1860 msc. But automatic validation still fails. I have no error in the code also in backtest no error. Automatic validation shows Tester takes too long time. How to get rid of this problem?

Regards

Alain Verleyen
Moderator
33618
Alain Verleyen  
Somsri Sarkar:

Is there any limit on the lines of coding? 

What is the standard compilation time for automatic validation approval?

Update: I decreased the line of to 2400, now compilation time is 1860 msc. But automatic validation still fails. I have no error in the code also in backtest no error. Automatic validation shows Tester takes too long time. How to get rid of this problem?

Regards

It has nothing to do with the number of lines or compilation time.

Optimize your code !

Somsri Sarkar
3689
Somsri Sarkar  
datetime iTimeMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   ENUM_TIMEFRAMES timeframe = TFMigrate(tf);
   datetime Arr[];
   if(CopyTime(symbol, timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}

int iBarShiftMQL4(string symbol,
                  int tf,
                  datetime time,
                  bool exact=false)
  {
   if(time<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[],time1;
   CopyTime(symbol,timeframe,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
  }

double iOpenMQL4(string symbol,int tf,int index)

{  
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyOpen(symbol,timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
Can the above function slow down the program?
Alain Verleyen
Moderator
33618
Alain Verleyen  
Somsri Sarkar:
datetime iTimeMQL4(string symbol,int tf,int index)

{
   if(index < 0) return(-1);
   ENUM_TIMEFRAMES timeframe = TFMigrate(tf);
   datetime Arr[];
   if(CopyTime(symbol, timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}

int iBarShiftMQL4(string symbol,
                  int tf,
                  datetime time,
                  bool exact=false)
  {
   if(time<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[],time1;
   CopyTime(symbol,timeframe,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
  }

double iOpenMQL4(string symbol,int tf,int index)

{  
   if(index < 0) return(-1);
   double Arr[];
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   if(CopyOpen(symbol,timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
Can the above function slow down the program?
For sure they can and they do.
Somsri Sarkar
3689
Somsri Sarkar  
Alain Verleyen:
For sure they can and they do.

Hi I searched about it in here, I found your article . From there I used ibarshifFast code. But automatic validation is still falling as I still have iOpen,iTime code. Like the ibarshiftFast code is there any similar code available for iOpen or iTime alternatives which will load faster?

Thank you

little bit code improvement I can do from my side is ,

double iOpenMQL4(string symbol,ENUM_TIMEFRAMES timeframe,int index)

{  
   if(index < 0) return(-1);
   double Arr[];
   if(CopyOpen(symbol,timeframe, index, 1, Arr)>0)
        return(Arr[0]);
   else return(-1);
}
Somsri Sarkar
3689
Somsri Sarkar  
I changed all mql4 to mql5 migration code, added all manually with copyTime, CopyOpen etc. But validation is still failing. 
Stanislav Korotky
22531
Stanislav Korotky  
Somsri Sarkar:
I changed all mql4 to mql5 migration code, added all manually with copyTime, CopyOpen etc. But validation is still failing. 
Run the built-in profiler and try to optimize/remove most lengthy parts of code.
Somsri Sarkar
3689
Somsri Sarkar  
Stanislav Korotky:
Run the built-in profiler and try to optimize/remove most lengthy parts of code.

Hello, Thank you so much for the profiler suggestion, I am learning about it.

I got followings, in my case in build function oncalculate is taking 95% execution time. Now how to deal with it. I can not remove oncalculate.

Mt4 version has same, but it has no problem with automatic validation working fine.

 

honest_knave
Moderator
2295
honest_knave  
Split the code in OnCalculate into smaller functions, then re-run the profiler.
12
To add comments, please log in or register