I get "tested with error 'critical runtime error 0 in OnInit function (error code 0 ..., line 1, col 1)' ... " when using MQL5 cloud agents
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":
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!

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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: