Help me debug error 4802

 

UPDATE ... the issue is resolved, I was adding file extension in iCustom Indicator Name. Once removed it, it works well.

Dear Forum Members

It is never easy to use iCustom function in MQL5.

Please help me to debug why I am getting error 4802.

I have checked all the input variables of the indicator, nothing seems to be missing. Indicator .ex5 is attached for convenient debugging of Class and Test EA.

Indicator INPUT parameters ...

  #property description "Volume Weighted Exponential Moving Average Indicator"
  #property description "3 EMAs ... Fastest, Fast and Slow"
  #include  "C:\Users\Anil Varma\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\AKTAdvisor\Auxiliary\Enums.mqh"

  #property indicator_chart_window
  #property indicator_buffers 3
  #property indicator_plots   3
//+----------------------------------------------------------------------------------------------------------+
//| Define Input Parameters
//+----------------------------------------------------------------------------------------------------------+
  input int                 inpMAPeriod_Fastest = 5;            // Fastest Averaging period
  input int                 inpMAPeriod_Fast    = 13;           // Fast Averaging period
  input int                 inpMAPeriod_Slow    = 21;           // Slow Averaging period
  input enum_APPLIED_PRICE  inpAppliedPrice     = price_CLOSE;  // Applied Price from Custom 'enum_APPLIED_PRICE'
  input bool                inpVolumeReal       = false;        // if 'true' = use real volume

CLASS to use the custom Indicator ...

class CiVW_3EMAs
  {
private:
  //--- class variable for parameters
    string              m_Symbol;
    ENUM_TIMEFRAMES     m_TimeFrame;
    int                 m_HandleEMA;          // Indicator handle
    string              m_IndicatorName;      // iCustom needs Custom Indicator name located in Indicator folder
  //--- Parameters for Exponential Moving Average(s)
    int                 m_MAPeriod_Fastest;   // Fastest Averaging Period
    int                 m_MAPeriod_Fast;      // Fast Averaging Period
    int                 m_MAPeriod_Slow;      // Slow Averaging Period
    enum_APPLIED_PRICE  m_AppliedPrice;       // Applied Price TYPE
    bool                m_VolumeReal;         // true = 'real' / false 'tick' volume type
  //---
    //CLog*             m_log;                // Logging

public:
  //--- Parametric Contstructor and default Destructor methods
          CiVW_3EMAs(string pSymbol,ENUM_TIMEFRAMES pTimeFrame,int pMAPeriodFastest,int pMAPeriodFast,
                     int pMAPeriodSlow,enum_APPLIED_PRICE pAppliedPrice);
         ~CiVW_3EMAs(void);
    void  Init_Handle(void);
  //--- Specific methods to get values from Custome Indicator 'iFx VW_3EMAs'
    bool  Get_3EMA(const int pBarCount,s_3EMA &psa3EMA); // with StructureArray
    //bool  Get_3EMAs(const int pBarCount,double &pEMAFastest[],double &pEMAFast[],double &pEMASlow[]);
    //bool  Get_EMAFastest(const int pBarCount,double &pEMAFastest[]);
  };
CiVW_3EMAs::CiVW_3EMAs(string pSymbol,ENUM_TIMEFRAMES pTimeFrame,int pMAPeriodFastest,int pMAPeriodFast,
                       int pMAPeriodSlow,enum_APPLIED_PRICE pAppliedPrice)
  {
    m_Symbol            = pSymbol;
    m_TimeFrame         = pTimeFrame;
    m_IndicatorName     = "Final Version\\iFx VW_3EMAs.mqh";
    m_MAPeriod_Fastest  = pMAPeriodFastest;
    m_MAPeriod_Fast     = pMAPeriodFast;
    m_MAPeriod_Slow     = pMAPeriodSlow;
    m_AppliedPrice      = pAppliedPrice;
    m_VolumeReal        = false;        // 'false' default volume Type set as Tick Volume
    //m_log = CLog::GetLog();
  } // END Of CiVW_3EMAs()

Error message ...

2021.05.28 16:39:59.621 EATest iVW_3EMAs (US30,M5) CiVW_3EMAs::Init_Handle: Error Creating iFx VW_3EMAs handle. Code 4807

2021.05.28 16:39:59.622 EATest iVW_3EMAs (US30,M5) cannot load custom indicator 'Final Version\iFx VW_3EMAs.mqh' [4802]

Test EA Code 

      #include "\..\Auxiliary\Enums.mqh"
  #include "\..\Indicator\CiVW_3EMAs.mqh"
//+----------------------------------------------------------------------------------------------------------+
//| Define 'global variables' used in EA
//+----------------------------------------------------------------------------------------------------------+
  string              ea_Symbol        = _Symbol;
  ENUM_TIMEFRAMES     ea_TFM05         = PERIOD_M5;
  int                 MAPeriod_Fastest = 5;            // Fastest Averaging period
  int                 MAPeriod_Fast    = 13;           // Fast Averaging period
  int                 MAPeriod_Slow    = 21;           // Slow Averaging period
  enum_APPLIED_PRICE  AppliedPrice     = price_CLOSE;  // Applied Price from Custom 'enum_APPLIED_PRICE'
  bool                VolumeReal       = false;        // if 'true' = use real volume
//+----------------------------------------------------------------------------------------------------------+
//| INCLUDE MQL5 or Custom 'CLASS' files and create instances of them
//+----------------------------------------------------------------------------------------------------------+
  CiVW_3EMAs          EMA_M05(ea_Symbol,ea_TFM05,MAPeriod_Fastest,MAPeriod_Fast,MAPeriod_Slow,AppliedPrice);
//+----------------------------------------------------------------------------------------------------------+
//| Expert initialization function
//+----------------------------------------------------------------------------------------------------------+
int OnInit()
  {
//---
    EMA_M05.Init_Handle();
//---
    return(INIT_SUCCEEDED);
  }
//+----------------------------------------------------------------------------------------------------------+
//| Expert de initialization function
//+----------------------------------------------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+----------------------------------------------------------------------------------------------------------+
//| Expert tick function
//+----------------------------------------------------------------------------------------------------------+
void OnTick()
  {
    int barStart = 0, barCount = 5, index = 1;
  //---
    if(IsNewBar())    // Check every 5 minute ...
      {
        s_3EMA  M05_EMA;
        EMA_M05.Get_3EMA(barCount,M05_EMA);
        Print("Fastest [1] ",DoubleToString(M05_EMA.Fastest[1],_Digits)," [2] ",DoubleToString(M05_EMA.Fastest[2],_Digits)," [3] ",DoubleToString(M05_EMA.Fastest[3],_Digits));
        Print("Fast    [1] ",DoubleToString(M05_EMA.Fast[1],_Digits)," [2] ",DoubleToString(M05_EMA.Fast[2],_Digits)," [3] ",DoubleToString(M05_EMA.Fast[3],_Digits));
        Print("Slow    [1] ",DoubleToString(M05_EMA.Slow[1],_Digits)," [2] ",DoubleToString(M05_EMA.Slow[2],_Digits)," [3] ",DoubleToString(M05_EMA.Slow[3],_Digits));
      }
  } // END Of expert advisor
//+----------------------------------------------------------------------------------------------------------+
//| METHOD:       IsNewBar()
//| APPLICATION:  Check if it is a New Candle on specified instrument & Time Frame
//+----------------------------------------------------------------------------------------------------------+
bool IsNewBar(void)
{
  bool   newBar;
  static datetime dtBarCurrent  = WRONG_VALUE;
         datetime dtBarPrevious = dtBarCurrent;
  // "SERIES_LASTBAR_DATE" Open time of the last bar of the symbol - period
  dtBarCurrent = (datetime)SeriesInfoInteger(ea_Symbol,ea_TFM05,SERIES_LASTBAR_DATE);  
  if(dtBarCurrent != dtBarPrevious)  newBar = true;
  else                               newBar = false;
  //---
  return(newBar);
} // END Of IsNewBar()
//+----------------------------------------------------------------------------------------------------------+


<*.ex* file deleted>

 

Make sure the Indicator is placed in teh correct directory as described in the documentation of iCustom:

https://www.mql5.com/en/docs/indicators/icustom

Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
iCustom - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Mathias Sebastian Kron:

Make sure the Indicator is placed in teh correct directory as described in the documentation of iCustom:

https://www.mql5.com/en/docs/indicators/icustom

Hi Mathias

yes the indicator is in correct folder / directory and path is also defined correctly.

as I am using the same folder / path for another couple of other indicators and they all are working fine.

 

You have to study how Metatrader file sandbox looks like and how to reference files. 

Do your includes work at all? Especially that one which starts with "C:\..." and those that start with "\..\".

Anyway, this is wrong:

    m_IndicatorName     = "Final Version\\iFx VW_3EMAs.mqh";

Here you have at least two problems:

  • you can't use extension mqh, it's ex5
  • if you call this from an expert, "m_indicatorname" without backslash character at the beginning would be appended to the current folder and indicator name as you wrote it resolves to: 
\Experts\{some folder where your expert is}\Final Version\iFx VW_3EMAs.mqh

Your indicator is in "Indicators" folder, probably something like this:

\Indicators\{some folder}\Final Version\iFx VW_3EMAs.ex5
 
Drazen Penic:

You have to study how Metatrader file sandbox looks like and how to reference files. 

Do your includes work at all? Especially that one which starts with "C:\..." and those that start with "\..\". SORTED OUT WITH"\..\..\xxxx i.e. going 2 steps behind in directory path

Anyway, this is wrong:

Here you have at least two problems:

  • you can't use extension mqh, it's ex5
  • if you call this from an expert, "m_indicatorname" without backslash character at the beginning would be appended to the current folder and indicator name as you wrote it resolves to: 
I plan to use Class always for indicator calls, but will keep this point in mind, in case I need to call Indicator within Expert
\Experts\{some folder where your expert is}\Final Version\iFx VW_3EMAs.mqh

Your indicator is in "Indicators" folder, probably something like this:

Thanks a lot Drazen for your reply.

removing extension mqh, (what a silly mistake) worked and CLASS and EA is working now.

about the second part of your answer, the result differs.

************************************************************************************************

My EA Location : MQL5\Experts\AKTAdvisor\Testing EAs\EATest iVW 3EMAs.mq5

My CLASS Location MQL5\Experts\AKTAdvisor\Indicator\CiVW_3EMAs.mqh

My Indicator Location : MQL5\Indicators\Final Version\iFx VW_MACD.ex5

************************************************************************************************

I am not sure why, but the following call in CLASS CiVW_3EMAs.mhq and than initialization of this class into EATest iVW_3EMAs.mqh is working well for this as well as for few other Classes I have created.

 m_IndicatorName     = "Final Version\\iFx VW_3EMAs";  // without file extension

Include statement in EATest iVW_3EMAs.mq5 is as below

  #include "\..\Indicator\CiVW_3EMAs.mqh"

Currently this set up working well, except my silly mistake of adding file extension to IndicatorName.

However, I am open to learn better ways of coding and save time in future with errors. Your suggestion for structure array really helped me a lot, and I almost revising few of my initial work on those lines.

It is really having impact on my EA with less number of arrays to handle and less calls to different indicators. I have successfully merged 3 Indicator calls 1) %b, 2) %MFI and 3) %RSI into one single CLASS with following structure.

struct  struct_NormBMR
  {
    double   NormBB;
    double   NormMFI;
    double   NormRSI;
  }

struct_NormBMR = sM05_NormBRM[];

Once again thanks a lot for your guidance and hopeful to receive them in future too.

regards

 
Vladimir Karputov:

Thanks Vladimir

iCustom now (and even with the help of a resource) works for me. !!! What you mean by this ?