I get "tested with error 'critical runtime error 0 in OnInit function (error code 0 ..., line 1, col 1)' ... " when using MQL5 cloud agents

 

I am doing a big optimisation for one of my EAs. Turns out my local machine and local network agents won't cut it, so I opted into the MQL5 cloud network. Anytime I enable MQL5 cloud agents I get the above error. It's still deducting money from my MQL5 account though.

What's up with that error? I can optimize on my local machine and my local network without any issues...

Thanks for any help!

//edit: In case it helps (I somewhat think it's irrelevant though because local optimization is fine), this is my OnInit function. It's basically just a bunch of Indicator handles:

int OnInit(){
   //--- Damit die Indis kommen:
   ChartOpen(Pair1, PERIOD_M15);
   ChartOpen(Pair2, PERIOD_M15);

   //--------------------------------------------------------Handles for Pair1
   //--- Moving Average Handle
   hMA1 = iMA(Pair1, NULL, MAPeriod, 0, MODE_SMA, PRICE_CLOSE);
   if(hMA1 == INVALID_HANDLE){Print("Error creating Moving Average indicator");}
   
   //--- Correlation Indi Handle
   hCorr1 = iCustom(Pair1, NULL, "Examples\\Custom\\currency-correlation\\Correlation", CorrPeriod, Pair1, Pair2);   
   if(hCorr1 == INVALID_HANDLE){Print("Error creating Correlation indicator");}

   //--- ATR Handle
   hATR1 = iATR(Pair1, NULL, 14);
   if(hATR1 == INVALID_HANDLE){Print("Error creating ATR");}
   
   //--- ASH Handle
   hASH1 = iCustom(Pair1, NULL, "Examples\\Custom\\ASH");
   if(hASH1 == INVALID_HANDLE){Print("Error creating ASH");}
   
   //--- Gann High Low Activator (GHLA) Hendl
   hGHLA1 = iCustom(Pair1, NULL, "Examples\\Custom\\gann-high-low-activator-ssl-alert", GHLAperiod, MODE_SMMA, false, false);   
   if(hGHLA1 == INVALID_HANDLE){Print("Error creating GHLA");}

   //--- Waddah Attar Explosion Handle
   hWAE1 = iCustom(Pair1, NULL, "Examples\\Custom\\waddah\\waddah_attar_explosion", WAE1, WAE2, WAE3, WAE4, WAE5, WAE6, WAE7, WAE8, true, 2, true, true, true, true);
   if(hWAE1 == INVALID_HANDLE){Print("Error creating WAE");}

   //--------------------------------------------------------Handles for Pair2
   //--- Moving Average Handle
   hMA2 = iMA(Pair2, NULL, MAPeriod, 0, MODE_SMA, PRICE_CLOSE);
   if(hMA2 == INVALID_HANDLE){Print("Error creating Moving Average indicator");}
   
   //--- Correlation Indi Handle - brauch ich eigentlich nicht
   hCorr2 = iCustom(Pair2, NULL, "Examples\\Custom\\currency-correlation\\Correlation", CorrPeriod, Pair1, Pair2);   
   if(hCorr2 == INVALID_HANDLE){Print("Error creating Correlation indicator");}

   //--- ATR Handle
   hATR2 = iATR(Pair2, NULL, 14);
   if(hATR2 == INVALID_HANDLE){Print("Error creating ATR");}
   
   //--- ASH Handle
   hASH2 = iCustom(Pair2, NULL, "Examples\\Custom\\ASH");
   if(hASH2 == INVALID_HANDLE){Print("Error creating ASH");}
   
   //--- Gann High Low Activator (GHLA) Hendl
   hGHLA2 = iCustom(Pair2, NULL, "Examples\\Custom\\gann-high-low-activator-ssl-alert", GHLAperiod, MODE_SMMA, false, false);   
   if(hGHLA2 == INVALID_HANDLE){Print("Error creating GHLA");}

   //--- Waddah Attar Explosion Handle
   hWAE2 = iCustom(Pair2, NULL, "Examples\\Custom\\waddah\\waddah_attar_explosion", WAE1, WAE2, WAE3, WAE4, WAE5, WAE6, WAE7, WAE8, true, 2, true, true, true, true);
   if(hWAE2 == INVALID_HANDLE){Print("Error creating WAE");}
   

   //--------------------------------------------------------Other Stuff

   //--- CTrade Log Level
   trade.LogLevel(1);
   
   //--- Done   
   return(INIT_SUCCEEDED);
  }
Distributed Computing in the MQL5 Cloud Network
Distributed Computing in the MQL5 Cloud Network
  • cloud.mql5.com
Today's computers spend most of their time idle and do not use all the features of their CPU. Now you can benefit from the spare power of your PC. You can sell your computer's CPU time to other members of our network community for a variety of tasks like optimizing Expert Advisors optimization or developing mathematical models. Join the MQL5...
 
I get that as well, sometimes on all passes, sometimes on some. This is very annoying, and should be fixed, or at least give out a meaningful message. When the errors are too many I can't run the MQL5 Cloud network again for a long time, it stops immediately with the error "...stop using of cloud servers because of ... critical errors".

 

The help says: when testing, you need to add a symbol to the market overview.

That is, you need to add lines like this:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   SymbolSelect(Pair1,true);
   SymbolSelect(Pair2,true);


In addition, if it was not immediately possible to create an indicator, you SHOULD analyze the error number and make a decision ...

 

I had the same problems here (and also using Custom Indicators), and after a very profitable chat with Mr. Alain Verleyen, I solved the problem.

Since I believe the issue was solved due to a set of actions, I prefer to list them all:


  • At the top of your EA, add the TESTER_INDICATOR property for all your indicators:

  • Start your OnInit() event with SymbolSelect(). Eg.  SymbolSelect("GBPUSD", true);
  • If you use any customized "return code" (useful in some cases to see in LOG/journal where and what happened), discard them. Use only the ENUM_INIT_RETCODE;
  • I created a boolean parameter called "IsCloud" to allow me to execute separated/different codes when testing in Cloud environment and when not. You will see below why...
  • Do not use CHART commands. Change all INDICATOR calls as follows, duplicating them in within an IF-ELSE that checks the boolean "IsCloud":

eg.

IF(!IsCloud)

ELSE


Notice that I'm NOT using any call or positioning to CHART is the EA will execute in Cloud Tester. It won't affect your critics and I believe that the Cloud Strategy Tester is not aware (like the Local Tester) in relation to discard the CHART (and PRINT and LOG).


  • Disable ALL your initial BROKER and ACCOUNT data. Change them for "defaults" according to the above IF-ELSE statement based on "IsCloud".
  • Also, if you check BALANCE and some financial data in your broker account, put it within the IF-ELSE and assume some defaults;
  • Important: only after the above steps I could see that ONE of my custom indicators was in DEBUG MODE (when we run it alone from MetaEditor to see some particular effect or procedure). It was shown in the JOURNAL during the test and it avoids the execution of your EA. Open again the respective MQ5 and compile it again - just that!
  • I started the test using only ONE cloud provider (USA).


Yes, all the above could be shown by METATRADER in much more detailed LOG/JOURNAL than a simple "error 0 in line 1 column 1".

It is really annoying and I hope these procedures help you and others.

And again, I appreciate Alain Verleyen for enlighting me in some aspects above.

Good luck!



Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Функции обработки событий - Функции - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5