Download MetaTrader 5

How to publicize the m_data[], when derive a class from CArrayDouble?

To add comments, please log in or register
Learning MQL5? Start with documentation!
Loong 2010.02.09 13:08 

I need a public buffer to use in CLoongIndiSelect::GetData().
I can define a public buffer, but there is a double m_data[].
So, why do not use it?

// CLoongIndiBuffer << CIndicatorBuffer << CArrayDouble << CArray << CObject
// need a public buffer                     protected
// to use in                                 m_data[]
// CLoongIndiSelect::GetData
class CLoongIndiBuffer : public CIndicatorBuffer
   //CObject* ReturnPointer(double& buffer[]) {return (CObject*)buffer;}
   double m_buffer[]; //need a public buffer to use in CLoongIndiSelect::GetData
   //It can run. But I want to use the m_data[] that inherit from CArrayDouble
   //How to publicize the m_data[] in CArrayDouble?
   //I have tried these code, they are error.
   //double* GetBuffer() {return m_data;}
   //double[] GetBuffer() {return m_data;}
   //CObject* GetBuffer() {ReturnPointer(m_data);}
   //CObject* GetBuffer() {return (CObject*)(m_data[]);}

   bool SetIndexBuffer(int index, ENUM_INDEXBUFFER_TYPE data_type=INDICATOR_DATA)
   {return ::SetIndexBuffer(index, m_buffer, data_type);}
   //{return ::SetIndexBuffer(index, m_data, data_type);}

class CLoongIndiSelect : public CIndicator
   bool Initialize(string symbol,ENUM_TIMEFRAMES period,ENUM_INDICATOR iIndiType);
   bool CreateBuffers(string symbol,ENUM_TIMEFRAMES period,int buffers);
   bool Create(string symbol,ENUM_TIMEFRAMES period,ENUM_INDICATOR type,int num_params,MqlParam &params[]);
   //bool SetIndexBuffer(int index, ENUM_INDEXBUFFER_TYPE data_type=INDICATOR_DATA)
   //{return ::SetIndexBuffer(index, indBuffer[index].m_buffer, data_type);}
   int  GetData(int count)
      CLoongIndiBuffer *pIndiBuffer;
      for(int i=0; i<iNumLines; i++)
         pIndiBuffer = At(i);
         if (false==GetData(0, count, i, pIndiBuffer.m_buffer))return(false);
         //if (false==GetData(0, count, i, pIndiBuffer.m_data))return(false);
         // I want to use m_data
testindi.mq5 3 kb
To add comments, please log in or register