Download MetaTrader 5
To add comments, please log in or register
Interested in social trading? Read the article!
danjeu
38
danjeu 2013.08.31 00:59 

when i run my strategy tester i have in the journal :

CIdicator::GetData:Invalid buffer

please can you help me

thanks 

Alain Verleyen
Moderator
28693
Alain Verleyen 2013.08.31 09:29  
danjeu:

when i run my strategy tester i have in the journal :

CIdicator::GetData:Invalid buffer

please can you help me

thanks 

It can help if we see the code...
danjeu
38
danjeu 2013.09.01 22:42  
angevoyageur:
It can help if we see the code...
danjeu
38
danjeu 2013.09.01 23:00  

my program use  the cross of  2 ma (mode EMA and SMA)

there is no error of compilations and it run but don't make any  trades and in the journal  i have CIdicator::GetData:Invalid buffer

 can you help me

thanks 

Files:
MA_CROISE.mqh 12 kb
cccc.mq5 7 kb
Alain Verleyen
Moderator
28693
Alain Verleyen 2013.09.01 23:53  
danjeu:

my program use  the cross of  2 ma (mode EMA and SMA)

there is no error of compilations and it run but don't make any  trades and in the journal  i have CIdicator::GetData:Invalid buffer

 can you help me

thanks 

The error occurs when getting value of slow_ma, fast_ma is ok. But I don't found why...not yet.

Done. Attached is your MA_CROISE.mqh corrected. When you copy & paste code, don't forget to replace all occurrences of variable's name.

//+------------------------------------------------------------------+
//| Creates the "Slow MA" indicator                                  |
//+------------------------------------------------------------------+
bool  MA_CROISE::CreateSlowMA(CIndicators *indicators)
  {
//--- Checking the pointer
   if(indicators==NULL) return(false);
//--- Adding an object to the collection
   if(!indicators.Add(GetPointer(m_slow_ma)))
     {
      printf(__FUNCTION__+": Error adding an object of the slow MA");
      return(false);
     }
//--- Setting parameters of the slow MA
   MqlParam parameters[4];
//---
   parameters[0].type=TYPE_STRING;
   parameters[0].string_value="Examples\\Custom Moving Average.ex5";
   parameters[1].type=TYPE_INT;
   parameters[1].integer_value=m_period_slow;      // Period
   parameters[2].type=TYPE_INT;
   parameters[2].integer_value=0;                  // Shift
   parameters[3].type=TYPE_INT;
   parameters[3].integer_value=m_method_slow;      // Averaging method
//--- Object initialization  
   if(!m_fast_ma m_slow_ma.Create(m_symbol.Name(),m_period,IND_CUSTOM,4,parameters))
     {
      printf(__FUNCTION__+": Error initializing the object of the fast MA");
      return(false);
     }
//--- Number of buffers
   if(!m_fast_ma m_slow_ma.NumBuffers(1)) return(false);
//--- Reached this part, so the function was successful, return true

   return(true);
  }
Files:
MA_CROISE.mqh 12 kb
danjeu
38
danjeu 2013.09.02 00:23  
angevoyageur:

The error occurs when getting value of slow_ma, fast_ma is ok. But I don't found why...not yet.

Done. Attached is your MA_CROISE.mqh corrected. When you copy & paste code, don't forget to replace all occurrences of variable's name.

 

angevoyageur:

The error occurs when getting value of slow_ma, fast_ma is ok. But I don't found why...not yet.

Done. Attached is your MA_CROISE.mqh corrected. When you copy & paste code, don't forget to replace all occurrences of variable's name.

 Great!  Thank you.

 

/
To add comments, please log in or register