Download MetaTrader 5

member function not defined

To add comments, please log in or register
Simon Blum
1059
Simon Blum 2014.01.31 13:15 

Maybe Someone can help me

I have a problem with compiling and the error message is that "member function not defined"...

Thanks for helping me

here my Code:

class CPeriodCalculator
  {
private:
   double high[];
   double low[];
   double open[];
   double close[];

public:
                  CPeriodCalculator(void);
                  ~CPeriodCalculator(void);   
   int            SetMAPeriod(string pSymbol, ENUM_TIMEFRAMES pPeriod, string pSpeed,double pX, double pY); 
   int            SetMAPeriod_Current(string pSymbol, ENUM_TIMEFRAMES pPeriod, string pSpeed, double pX, double pY); 
   

                    
  };
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CPeriodCalculator::CPeriodCalculator(void) 
  {
      ArraySetAsSeries(high, true);
      ArraySetAsSeries(low, true);
      ArraySetAsSeries(open, true);
      ArraySetAsSeries(close, true); 
  }
 
  
//+------------------------------------------------------------------+
//|Function to Calculate the MA Periods                              |
//+------------------------------------------------------------------+
int CPeriodCalculator::SetMAPeriod(string pSymbol, ENUM_TIMEFRAMES pPeriod, string pSpeed, double pX, double pY) 
  {
      
      CopyHigh(pSymbol,pPeriod,0,2,high);
      CopyLow(pSymbol, pPeriod,0,2,low);
      CopyOpen(pSymbol, pPeriod,0,2,open);
      CopyClose(pSymbol, pPeriod,0,2,close);
      
      if (StringCompare(pSpeed,"fast",false) == 0)
         {
            return (MathRound( (1/30)* (((high[1] - low[1]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY))));
         }
      else if (StringCompare(pSpeed,"moderate",false) == 0)
         {
            return (MathRound(((high[1] - low[1]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY)));
         }
      else if (StringCompare(pSpeed,"slow",false) == 0)
         {
            return (2 * MathRound(((high[1] - low[1]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY)));
         }
      else return(-1);
  }
//+------------------------------------------------------------------+
//| Function to Calculate the MA Periods by highest High/lowest Low  |
//+------------------------------------------------------------------+
int CPeriodCalculator::SetMAPeriod_Current(string pSymbol, ENUM_TIMEFRAMES pPeriod, string pSpeed, double pX, double pY)
  {
      
      CopyHigh(pSymbol,pPeriod,0,2,high);
      CopyLow(pSymbol, pPeriod,0,2,low);
      CopyOpen(pSymbol, pPeriod,0,2,open);
      CopyClose(pSymbol, pPeriod,0,2,close);
      int maxIdx = ArrayMaximum(high);
      int minIdx = ArrayMinimum(low);
      
      if (StringCompare(pSpeed,"fast",false) == 0)
         {
            return (MathRound( (1/30)* (((high[maxIdx] - low[minIdx]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY))));
         }
      else if (StringCompare(pSpeed,"moderate",false) == 0)
         {
            return (MathRound(((high[maxIdx] - low[minIdx]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY)));
         }
      else if (StringCompare(pSpeed,"slow",false) == 0)
         {
            return (2 * MathRound(((high[maxIdx] - low[minIdx]) / _Point) * pX + MathAbs(((open[1] - close[1]) / _Point) * pY)));
         }
      else return(-1);
  }
  
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CPeriodCalculator::~CPeriodCalculator(void)
  {
  } 
Alain Verleyen
Moderator
31090
Alain Verleyen 2014.01.31 13:25  
1531691:

Maybe Someone can help me

I have a problem with compiling and the error message is that "member function not defined"...

Thanks for helping me

here my Code:

I don't get this error when compiling the code you provided.
Simon Blum
1059
Simon Blum 2014.01.31 13:34  
angevoyageur:
I don't get this error when compiling the code you provided.

Sorry my mistake...


I got this Problem when I try to call the function from my EA...


#include <Expert\BK\CPeriodCalculator.mqh>

//+------------------------------------------------------------------+
//| INPUT variables                                                  |
//+------------------------------------------------------------------+

//--- Input for pSymbols
input double   X_EURCHF    = 0.15;
input double   X_EURGBP    = 0.15;
input double   X_EURJPY    = 0.15;
input double   X_EURUSD    = 0.15;
input double   X_GBPJPY    = 0.15;
input double   X_GBPUSD    = 0.15;
input double   X_USDCHF    = 0.15;
input double   X_USDJPY    = 0.15;

input double   Y_EURCHF    = 0.2;
input double   Y_EURGBP    = 0.2;
input double   Y_EURJPY    = 0.2;
input double   Y_EURUSD    = 0.2;
input double   Y_GBPJPY    = 0.2;
input double   Y_GBPUSD    = 0.2;
input double   Y_USDCHF    = 0.2;
input double   Y_USDJPY    = 0.2;

//--- Inputs for MoneyManagement
input double             Money_FixLot_Percent          = 5;              // Percent
input double             Money_FixLot_Lots             = 0.5;            // Fixed volume

//+------------------------------------------------------------------+
//| Expert initialization variables                                  |
//+------------------------------------------------------------------+

//--- OBJECTS
CPeriodCalculator MAPeriod;

//--- ARRAYS
string sy[8];
double x[8];
double y[8];

int      tema_FastHandle[];
int      tema_ModerateHandle[];
int      tema_SlowHandle[];

//--- INTEGERS
int i = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetTimer(60);

//--- Setting Arrays as series


//--- ARRAYS 
   sy[0]="EURCHF"; sy[1]="EURGBP"; sy[2]="EURJPY"; sy[3]="EURUSD"; sy[4]="GBPJPY"; sy[5]="GBPUSD"; sy[6]="USDCHF"; sy[7]="USDJPY";
   x[0]=X_EURCHF; x[1]=X_EURGBP; x[2]=X_EURJPY; x[3]=X_EURUSD; x[4]=X_GBPJPY; x[5]=X_GBPUSD; x[6]=X_USDCHF; x[7]=X_USDJPY;
   y[0]=Y_EURCHF; y[1]=Y_EURGBP; y[2]=Y_EURJPY; y[3]=Y_EURUSD; y[4]=Y_GBPJPY; y[5]=Y_GBPUSD; y[6]=Y_USDCHF; y[7]=Y_USDJPY; 


   int Z = MAPeriod.SetMaPeriod(sy[0], PERIOD_D1, "fast", x[0], y[0]);


//---
   return(INIT_SUCCEEDED);
  }
Alain Verleyen
Moderator
31090
Alain Verleyen 2014.01.31 13:43  
1531691:

Sorry my mistake...


I got this Problem when I try to call the function from my EA...


The method defined in your class is SetMAPeriod and not SetMaPeriod. mql5 is case sensitive.
Simon Blum
1059
Simon Blum 2014.01.31 13:51  
angevoyageur:
The method defined in your class is SetMAPeriod and not SetMaPeriod. mql5 is case sensitive.
HA HA Thank YOU!!!
To add comments, please log in or register