what should be the name of the custom indicator in IndicatorCreate() function as first parameter if we import indicator in ExperAdvisor as resourse?

 
Hi and good day all
I really appreciated your help if let me know how to define the name of imported indicator as resource to the ExperAdvisor in  IndicatorCreate() function.
As you know probably we have to pass the name of custom indicator as first parameter.
The case when a custom indicator handle is created in OnInit() function. FYI I have read this page but I could not find my answer.
#resource "\\Indicators\\Indicator.ex5"

// ============================
MqlParam Indicator_Params[];
      ArrayResize(QQE_Params_4T,8);
      Indicator_Params.type         =TYPE_STRING;
      Indicator_Params.string_value=Name_of_Indicator;  ===> ???? (how to define it since its custom indicator 

// ============================
int  IndicatorCreate(
   string           symbol,                            // symbol name
   ENUM_TIMEFRAMES  period,                            // timeframe
   ENUM_INDICATOR   indicator_type,                    // indicator type from the enumeration ENUM_INDICATOR
   int              parameters_cnt=0,                  // number of parameters
   const MqlParam&  parameters_array[]=NULL,           // array of parameters
   );
Thanks in advance
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
 
Thanks for sharing this dear William but I am using the CiCustom class which using the create function inside the create function as you can see the IndicatorCreate function has been called by passing the params which should be the include name of the indicator
how to define the name, btw I have tried what you have suggested ( ::Indicators\\indicator.ex5 ) as name of indicator but still it could not find it and load the indicator.
let say you have indicator and you imported as follow
#resource "\\Indicators\\name_custom_indicator.ex5"
then how would you name it if you are going to pass it as param to create function of CiCustom class,

MqlParam Indicator_Params[];
      ArrayResize(QQE_Params_4T,8);
      Indicator_Params.type         =TYPE_STRING;
      Indicator_Params.string_value="::Indicators\\name_custom_indicator.ex5";  ===> ???? you will define it like this, not worked for me.
 create function of CiCustom class
//+------------------------------------------------------------------+
//| Creation of the indicator with universal parameters              |
//+------------------------------------------------------------------+
bool CIndicator::Create(const string symbol,const ENUM_TIMEFRAMES period,
                        const ENUM_INDICATOR type,const int num_params,const MqlParam &params[])
  {
//--- check history
   if(!SetSymbolPeriod(symbol,period))
      return(false);
//--- create
   m_handle=IndicatorCreate(symbol,period,type,num_params,params);
//--- check result
   if(m_handle==INVALID_HANDLE)
      return(false);
//--- idicator successfully created
   if(!Initialize(symbol,period,num_params,params))
     {
      //--- initialization failed
      IndicatorRelease(m_handle);
      m_handle=INVALID_HANDLE;
      return(false);
     }
//--- ok
   return(true);
  }
Thanks
 
Read the documentation about resource it's right there with code example.
 
Alain Verleyen:
Read the documentation about resource it's right there with code example.
Thanks dear Alian
if you are referring to this page and GetRelativeProgramPath();
I have used this but for your information it will return the directory of ExperAdvisor and name of it.
lets say I have multiple indicator as resource how can I distinguish this.

  string path=GetRelativeProgramPath();
//--- indicator buffers mapping
   handle=iCustom(_Symbol,_Period,path,0,0);
   if(handle==INVALID_HANDLE)
     {
based on the above code I have to define my Indicator params which include the name as below but it is not working
MqlParam Indicator_Params[];
      ArrayResize(QQE_Params_4T,8);
      Indicator_Params.type         =TYPE_STRING;
      Indicator_Params.string_value= GetRelativeProgramPath();  ===> ???? will you define it like??? 
it has not worked for me
Please let me know what should I define in Indicator_Params.string_value= ??????
Thanks in advance
Documentation on MQL5: MQL5 programs / Resources
Documentation on MQL5: MQL5 programs / Resources
  • www.mql5.com
Resources - MQL5 programs - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
???? will you define it like??? 

Of course not. I have no idea what you are trying to do. Post all the needed code that COMPILES, if you need coding help. Your snippets are useless.

 
Alain Verleyen:

Of course not. I have no idea what you are trying to do. Post all the needed code that COMPILES, if you need coding help. Your snippets are useless.

Ok sure this my EA code
I have QQE indicator which I have imported as resource and I want to create handle of this indicator and use it in my code later.
this is error I received whenever I run my EA.
2021.07.26 14:18:24.882    2021.07.01 00:00:00   custom indicator 'Test\TestCustomIndicator.ex5' cannot load [4802].

//+------------------------------------------------------------------+
//|                                          TestCustomIndicator.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
#include <Indicators\Custom.mqh>
#resource "\\Indicators\\Z_QQE.ex5"
CiCustom QQE_Indicator;
int QQE_Handle;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   CreateQQEHandles();
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
bool CreateQQEHandles()
  {
   int Rsi_Period                         = 14;
   int Rsi_Smoothing_Factor               = 5;
   double Fast_Period                     = 2.618;
   double Slow_Period                     = 4.236;
   string path=GetRelativeProgramPath();
   MqlParam QQE_Params[];
   ArrayResize(QQE_Params,8);
   QQE_Params[0].type         =TYPE_STRING;
   QQE_Params[0].string_value=path;
   QQE_Params[1].type         =TYPE_INT;
   QQE_Params[1].integer_value=Rsi_Period;
   QQE_Params[2].type         =TYPE_INT;
   QQE_Params[2].integer_value=Rsi_Smoothing_Factor;
   QQE_Params[3].type         =TYPE_DOUBLE;
   QQE_Params[3].double_value=Fast_Period;
   QQE_Params[4].type         =TYPE_DOUBLE;
   QQE_Params[4].double_value=Slow_Period;
   QQE_Params[5].type         =TYPE_INT;
   QQE_Params[5].integer_value=PRICE_CLOSE;

   QQE_Handle = QQE_Indicator.Create(_Symbol,PERIOD_H1,IND_CUSTOM,6,QQE_Params);
   if(!QQE_Handle)
     {
      printf(__FUNCTION__+": error initializing object");
      return(false);
     }
     return true;
  }
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+ 
//| GetRelativeProgramPath                                           | 
//+------------------------------------------------------------------+ 
string GetRelativeProgramPath() 
  { 
   int pos2; 
//--- get the absolute path to the application 
   string path=MQLInfoString(MQL_PROGRAM_PATH); 
//--- find the position of "\MQL5\" substring 
   int    pos =StringFind(path,"\\MQL5\\"); 
//--- substring not found - error 
   if(pos<0) 
      return(NULL); 
//--- skip "\MQL5" directory 
   pos+=5; 
//--- skip extra '\' symbols 
   while(StringGetCharacter(path,pos+1)=='\\') 
      pos++; 
//--- if this is a resource, return the path relative to MQL5 directory 
   if(StringFind(path,"::",pos)>=0) 
      return(StringSubstr(path,pos)); 
//--- find a separator for the first MQL5 subdirectory (for example, MQL5\Indicators) 
//--- if not found, return the path relative to MQL5 directory 
   if((pos2=StringFind(path,"\\",pos+1))<0) 
      return(StringSubstr(path,pos)); 
//--- return the path relative to the subdirectory (for example, MQL5\Indicators) 
   return(StringSubstr(path,pos2+1)); 
  } 
I hope it is clear now what I am trying to do
I just need to know what should I define the name of the custom indicator as param

   string path=GetRelativeProgramPath();
   MqlParam QQE_Params[];
   ArrayResize(QQE_Params,8);
   QQE_Params[0].type         =TYPE_STRING;
   QQE_Params[0].string_value=path;  =======> this path is NOT correct 
Thanks
Files:
Z_QQE.ex5  16 kb
 
Alain Verleyen:

Of course not. I have no idea what you are trying to do. Post all the needed code that COMPILES, if you need coding help. Your snippets are useless.

Dear @Alain Verleyen did you get the idea what I am trying the do
I need to know how to define the name (or maybe the path) of the custom indicator which imported as resources into the EA.
Really Appreciated your help.

 
HF2020:

Dear @Alain Verleyen did you get the idea what I am trying the do
I need to know how to define the name (or maybe the path) of the custom indicator which imported as resources into the EA.
Really Appreciated your help.

You should not try all and anything without understanding what you are doing.
   QQE_Params[0].string_value = "::Indicators\\Z_QQE.ex5";
Reason: