Automatic Validation problem

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

Hi Agallacherl

Optimize your code.

Thanks

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 !

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?

yes For sure they can and they do.

Thanks

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);
}

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.

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.

Split the code in OnCalculate into smaller functions, then re-run the profiler.