How to use function in EA which inherit from a Class. Get wrong parameter count.Please help

 

Hello, I need some help in finding my error in use inheritance from class CIndicatorMA. 

I have a Class CIndicator MA set up like this (it uses a Base class CIndicatorBase which deals with the buffers en index of indicators - not relevant for this question)..

class CIndicatorMA : public CIndicatorBase  {

private:

protected:
      int            mPeriod;
      int            mShift;
      ENUM_MA_METHOD mMethod;
      int            mAppliedPrice;
      
public:
      CIndicatorMA(string symbol, int timeframe, int period, ENUM_MA_METHOD method, int appliedPrice);
      ~CIndicatorMA();
   
};


CIndicatorMA::CIndicatorMA(string symbol, int timeframe, int period, ENUM_MA_METHOD method, int appliedPrice)
  : CIndicatorBase()  {
  
  mSymbol         =  symbol;
  mTimeframe      =  timeframe;
  mPeriod         =  period;
  mShift          =  0;
  mMethod         =  method;
  mAppliedPrice   =  appliedPrice;
  

CIndicatorMA::~CIndicatorMA()  {
}

Then I using the class CIndicator within an EA using the following code:

//This is where I use  the modular indicator classes
#include   "IndicatorMA.mqh"
CIndicatorMA   MAAnchorFast;
CIndicatorMA   MAAnchorSlow;
CIndicatorMA   MAMainFast;
CIndicatorMA   MAMainMid;
CIndicatorMA   MAMainSlow;


int OnInit()  {
   
   //Initialise the indicators
   MAAnchorFast.Init(Symbol(), InpAnchorTimeframe, InpAnchorFastPeriod, InpAnchorFastMethod, InpAnchorFastAppliedPrice);
   MAAnchorSlow.Init(Symbol(), InpAnchorTimeframe, InpAnchorSlowPeriod, InpAnchorSlowMethod, InpAnchorSlowAppliedPrice);
  
   MAMainFast.Init(Symbol(), Period(), InpMainFastPeriod, InpMainFastMethod,InpMainFastAppliedPrice);
   MAMainMid.Init(Symbol(), Period(), InpMainMidPeriod, InpMainMidMethod,InpMainMidAppliedPrice);
   MAMainSlow.Init(Symbol(), Period(), InpMainSlowPeriod, InpMainSlowMethod,InpMainSlowAppliedPrice);
    
   return(INIT_SUCCEEDED);
}

However when I compile I get the following error messages:

1. 'CIndicatorMA' - wrong parameter count

2. 'Init' - function not defined

The variables used in de different MA's are off course set up in the beginning of the EA.

What do I miss? Any help or hint would be very much appreciated.

Documentation on MQL5: Standard Library / Indicators / Base classes / CIndicator
Documentation on MQL5: Standard Library / Indicators / Base classes / CIndicator
  • www.mql5.com
CIndicator - Base classes - Indicators - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Learn to deal with classes, study the examples:

https://www.mql5.com/en/docs/basis/types/classes

https://www.mql5.com/en/articles/351: The Basics of Object-Oriented Programming

There is a lot more that all most probably will answer your question, just search here (top right the lens) for classes and select: Documentation, Articles, CodeBase, Forum, ..: https://www.mql5.com/en/search#!keyword=Classes

Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
Documentation on MQL5: Language Basics / Data Types / Structures, Classes and Interfaces
  • www.mql5.com
Structures, Classes and Interfaces - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
To initialize your class requires five parameters
CIndicatorMA(string symbol, int timeframe, int period, ENUM_MA_METHOD method, int appliedPrice);
You are trying to create five class instances with no parameters.
CIndicatorMA   MAAnchorFast;
CIndicatorMA   MAAnchorSlow;
CIndicatorMA   MAMainFast;
CIndicatorMA   MAMainMid;
CIndicatorMA   MAMainSlow;
Reason: