How can we possibly help you? Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
We can't see your broken code. Only you know why your OnInit is returning one (INIT_FAILED); Event Handling Functions - Functions - Language Basics - MQL4 Reference
Fix your broken code.
Irrevalent. We can't see his broken code. Only your coder knows why his OnInit is returning one (INIT_FAILED). Have him fix his broken code.
I think I have to mention that when I do optimization on local PC with multiple core, it does not have the error and it is able to complete. The error message happen when do optimization using MQL5 Cloud Network Agent.
Here is the code, appreciate any help:
//---===================== The OnInit function ======================================================= int OnInit() { stoplevel = (int)(SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL) + SymbolInfoInteger(_Symbol,SYMBOL_SPREAD) + SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL)); double LotStep = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP); if(LotStep >= 1) LotDigits = 0; else if(LotStep >= 0.1) LotDigits = 1; else if(LotStep >= 0.01) LotDigits = 2; else LotDigits = 3; pipoffset = NormalizeDouble(Distance * Point(), Digits()); //initialize crossed for (int i = 0; i < ArraySize(crossed); i++) crossed[i] = true; // if(Main_Detection==Indicator_1) { hull_handle = iCustom(Symbol(), Period(),indi,inpSchaffPeriod,inpFastPeriod,inpSlowPeriod,inpSmoothPeriod,inpPrice); if(hull_handle==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the hull_handle indicator for the symbol %s/%s, error code %d", EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } } // if(Main_Detection==Indicator_2) { cycle_handle = iCustom(Symbol(), Period(),indi2,SchaffPeriod,FastEma,SlowEma,SmoothPeriod,Price); if(cycle_handle==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the cycle_handle indicator for the symbol %s/%s, error code %d", EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } } // if(Use_ADX_Filter) { adx_handle = iADX(NULL, PERIOD_CURRENT,ADX_Period); if(adx_handle < 0) { Print("The creation of adx_handle has failed: adx_handle=", INVALID_HANDLE); Print("Runtime error = ", GetLastError()); return(INIT_FAILED); } } // if(Use_MA_Filter) { ma_handle = iMA(NULL,PERIOD_CURRENT,MA_Period,MA_Shift,MA_Method,MA_Price); if(ma_handle < 0) { Print("The creation of ma_handle has failed: ma_handle=", INVALID_HANDLE); Print("Runtime error = ", GetLastError()); return(INIT_FAILED); } ma2_handle = iMA(NULL,PERIOD_CURRENT,MA2_Period,MA2_Shift,MA2_Method,MA2_Price); if(ma2_handle < 0) { Print("The creation of ma2_handle has failed: ma_handle=", INVALID_HANDLE); Print("Runtime error = ", GetLastError()); return(INIT_FAILED); } } if(Use_Candle_Filter) { candle_handle = iCustom(Symbol(),PERIOD_CURRENT,"Daily open line",TimeShift); if(candle_handle < 0) { Print("The creation of candle_handle has failed: candle_handle=", INVALID_HANDLE); Print("Runtime error = ", GetLastError()); return(INIT_FAILED); } } return(0); } //---===================== The OnTick function ======================================================
- firecard: Here is the code,
Please edit your post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
hull_handle = iCustom(Symbol(),Period(),indi,inpSchaffPeriod,inpFastPeriod,inpSlowPeriod,inpSmoothPeriod,inpPrice); cycle_handle = iCustom(Symbol(), Period(),indi2,SchaffPeriod,FastEma,SlowEma,SmoothPeriod,Price); candle_handle = iCustom(Symbol(),PERIOD_CURRENT,"Daily open line",TimeShift);
The three indicators aren't part of your product. Therefor product can't use them except when running on your machine. Why does this surprise you when you try to use the cloud or Market Validation?
Just embed the other indicator(s) inside your indicator/EA. Add the CI(s) to your code as a resource.
Use the publicly released code - MQL5 programming forum 2017.02.20
Resources - MQL4 ReferenceBe aware that using resources is 40x times slower than using CIs directly.
A custom indicator as a resource - MQL4 programming forum 2019.11.26 -
stoplevel = (int)(SymbolInfoInteger(_Symbol,SYMBOL_TRADE_FREEZE_LEVEL) + SymbolInfoInteger(_Symbol,SYMBOL_SPREAD) + SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL));
Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
Just embed the other indicator(s) inside your indicator/EA. Add the CI(s) to your code as a resource.
Use the publicly released code - MQL5 programming forum 2017.02.20
Resources - MQL4 ReferenceBe aware that using resources is 40x times slower than using CIs directly.
A custom indicator as a resource - MQL4 programming forum 2019.11.2
Thank you for the reply, my coder did do the embedded version, when I try to run optimization at using cloud agent, I get:
2020.06.20 21:34:55.480 Tester obsolete version of resource "Experts\job 120487 indicator and trend 24.ex5::Indicators\trend cycle - Hull.ex5" can be used on local or remote agents only, no Cloud 21:36 2020.06.20 21:34:55.480 Tester obsolete version of resource "Experts\job 120487 indicator and trend 24.ex5::Indicators\Trend Cycle.ex5" can be used on local or remote agents only, no Cloud

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I ran optimization with MQL5 cloud network and I got this error: OnInit returned non-zero code 1. Can someone help me?
Full log at: