Tester stopped because OnInit returns non-zero code 1

 

Hello. Can someone please help with this error?

input group                "---- RSI ----"
input int                  RSIPeriod   =  14;            //Period
input ENUM_APPLIED_PRICE   RSIPrice    =  PRICE_CLOSE;   //Applied price
//---
input group                "---- CCI ----"
input int                  CCIPeriod   =  14;            //Period
input ENUM_APPLIED_PRICE   CCIPrice    =  PRICE_TYPICAL; //Applied price
//---
input group                "---- ATR ----"
input int                  ATRPeriod   =  14;            //Period
//---
input group                "---- MACD ----"
input int                  FastPeriod  =  12;            //Fast
input int                  SlowPeriod  =  26;            //Slow
input int                  SignalPeriod =  9;            //Signal
input ENUM_APPLIED_PRICE   MACDPrice   =  PRICE_CLOSE;   //Applied price
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
CSymbolInfo         Symb;
MqlRates            Rates[];
CNet                StudyNet;
CBufferFloat       *TempData;
CiRSI               RSI;
CiCCI               CCI;
CiATR               ATR;
CiMACD              MACD;
CTrade              Trade;
//---
float                dError;
datetime             dtStudied;
bool                 bEventStudy;
MqlDateTime          sTime;
//---
CBufferFloat         State;
datetime             lastBar;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(!Symb.Name(_Symbol))
      return INIT_FAILED;
   Symb.Refresh();
//---
   if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
      return INIT_FAILED;
//---
   if(!CCI.Create(Symb.Name(), TimeFrame, CCIPeriod, CCIPrice))
      return INIT_FAILED;
//---
   if(!ATR.Create(Symb.Name(), TimeFrame, ATRPeriod))
      return INIT_FAILED;
//---
   if(!MACD.Create(Symb.Name(), TimeFrame, FastPeriod, SlowPeriod, SignalPeriod, MACDPrice))
      return INIT_FAILED;
//---
   float temp1, temp2;
   if(!StudyNet.Load(FileName + ".nnw", dError, temp1, temp2, dtStudied, true))
      return INIT_FAILED;
//---
   if(!StudyNet.GetLayerOutput(0, TempData))
      return INIT_FAILED;
   HistoryBars = TempData.Total() / NeuronsToBar;
   StudyNet.getResults(TempData);
   if(TempData.Total() != Actions)
      return INIT_PARAMETERS_INCORRECT;
//---
   if(!RSI.BufferResize(HistoryBars + 2) || !CCI.BufferResize(HistoryBars + 2) ||
      !ATR.BufferResize(HistoryBars + 2) || !MACD.BufferResize(HistoryBars + 2))
      return INIT_FAILED;
//---
   lastBar = 0;
//---
   if(!Trade.SetTypeFillingBySymbol(Symb.Name()))
      return INIT_FAILED;
//---
   return(INIT_SUCCEEDED);
  }
 
Kekeletso Mofokeng:

Hello. Can someone please help with this error?

Try returning different integer values instead of using INIT_FAILED everywhere. You will notice what is failing.

 
The Alchemist #:

Try returning different integer values instead of using INIT_FAILED everywhere. You will notice what is failing.

For indicators ?
 
Kekeletso Mofokeng:

Hello. Can someone please help with this error?

I believe the error may be caused by one or more of the several classes from which you are attempting to create objects.   I believe it will be necessary for you to troubleshoot each class to ensure object instantiation can be achieved from the given class. 

Also print out the indicator name to locate the failure.

   if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
    printf("RSI");
   return INIT_FAILED;

OnInit - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

INIT_FAILED

Initialization failed. There is no point in continuing the test due to unavoidable errors. For example, it is impossible to create an indicator necessary for the EA operation.

The return of this value means the same as returning the value different from zero – EA initialization in the tester failed.

Documentation on MQL5: Event Handling / OnInit
Documentation on MQL5: Event Handling / OnInit
  • www.mql5.com
OnInit - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Max Brown #:

I believe the error may be caused by one or more of the several classes from which you are attempting to create objects.   I believe it will be necessary for you to troubleshoot each class to ensure object instantiation can be achieved from the given class. 



OnInit - Event Handling - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

INIT_FAILED

Initialization failed. There is no point in continuing the test due to unavoidable errors. For example, it is impossible to create an indicator necessary for the EA operation.

The return of this value means the same as returning the value different from zero – EA initialization in the tester failed.

Thank you 
 
Max Brown #:
Also print out the indicator name to locate the failure.
Thank you for all your help. May God bless you brother
 
Max Brown #:
Also print out the indicator name to locate the failure.

It's not printing anything but thanks for your help


   if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
      printf("RSI");
      return INIT_FAILED;
//---
   if(!CCI.Create(Symb.Name(), TimeFrame, CCIPeriod, CCIPrice))
      printf("CCI");
      return INIT_FAILED;
//---
   if(!ATR.Create(Symb.Name(), TimeFrame, ATRPeriod))
      printf("ATR");
      return INIT_FAILED;
//---
   if(!MACD.Create(Symb.Name(), TimeFrame, FastPeriod, SlowPeriod, SignalPeriod, MACDPrice))
      printf("MACD");
      return INIT_FAILED;
 
Kekeletso Mofokeng #:

It's not printing anything but thanks for your help


Please use curly brackets to make the return statment inside de IF clause. Probably your RSI is okay and your problem is below that.
 
Ricardo Rodrigues Lucca #:
Please use curly brackets to make the return statment inside de IF clause. Probably your RSI is okay and your problem is below that.

Still says error. thanks

 
The Alchemist #:

Try returning different integer values instead of using INIT_FAILED everywhere. You will notice what is failing.

That won't help.

The code needs to print the error.

 

Max Brown #:

if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
    printf("RSI");
   return INIT_FAILED;


Also print out the indicator name to locate the failure.

No braces mean that init will always fail!

It should be

if(!RSI.Create(Symb.Name(), TimeFrame, RSIPeriod, RSIPrice))
   {
    printf("RSI");
    return INIT_FAILED;
   }
Reason: