Use OPP to initialize Custom indicators has unclear to do so please advise..

 

Hello,

I found that Make the EA with MQL5 is a good to have a complex and fast trading EA. So I am starting to code however I have a problem in custom indicators.

It is necessary to pass some heavy calculation into the OnCalculation Functions for fast operation. So to use custom indicators is the thing that is a must.

I look to the two CiCustom and CIndicator  class because in the Class CiCustom have this code:

class CiCustom : public CIndicator

I am trying to create the custom indicator from the iCustom Class however in the code have not a point to give the program for Custom Indicator files name.

So I would like to know, what is the tick to play this.

  • in the CIndicator Class

bool CIndicator::Create(const string symbol,const ENUM_TIMEFRAMES period,const ENUM_INDICATOR type,const int num_params,const MqlParam &params[])

  • in the CiCustom Class

virtual bool      Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);

And this my code!!

   CiCustom          m_hw;

   MqlParam          m_hw_param[];

//

     m_hw_param[0].integer_value=m_number;

//--- initialize object

   if(!m_hw.Create(m_symbol.Name(),0,IND_CUSTOM,1,m_hw_param))  <--- where to set file name of custom indicators

     {

      printf(__FUNCTION__+": error initializing object");

      return(false);

     }

In normal we use this it have!

int  iCustom( 
   string           symbol,     // symbol name 
   ENUM_TIMEFRAMES  period,     // period 
   string           name        // folder/custom_indicator_name    <--- set file name here!!
   ...                          // list of indicator input parameters 
   );


If you are know, so please advise me.

Chaiya


 
  • in the CiCustom Class
virtual bool      Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);

The indicator name must be the first parameter. See IndicatorCreate.

If the indicator handle of IND_CUSTOM type is created, the type field of the first element of the array of input parameters parameters_array must have the TYPE_STRING value of the ENUM_DATATYPE enumeration, and the string_value field of the first element must contain the name of the custom indicator. The custom indicator must be compiled (file with EX5 extension) and located in the directory MQL5/Indicators of the client terminal or in a subdirectory.

Reason: