example of CiTime

 

Hi Guys,


Can you give an example how to use CiTime class in TimeSeries.mqh file to get open time of a bar?


CiTime

CiTime is a class designed for access to open times of the bars in the history.

Description

The CiTime class provides an access to open times of the bars in the history.

Declaration

   class CiTime: public CSeries

Title

   #include <Indicators\TimeSeries.mqh>

Class Methods

Create Methods

 

Create

Creates a timeseries

BufferResize

Sets buffer size

Data Access Methods

 

GetData

Gets the data

Data Update Methods

 

Refresh

Updates the data


//+------------------------------------------------------------------+
//| Method to access data.                                           |
//| INPUT:  index - position of element in the buffer.               |
//| OUTPUT: value - if successful, 0 otherwise.                      |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
datetime CiTime::GetData(int index) const
  {
   CTimeBuffer *buff=At(0);
//--- checking
   if(buff==NULL)
     {
      Print("CiSpread::GetData: invalid buffer");
      return(0);
     }
//---
   return((datetime)buff.At(index));
  }
//+------------------------------------------------------------------+
//| API access method "Copying the time buffer by specifying         |
//| start position and number of elements".                          |
//| INPUT:  start_pos - position of start element in the buffer,     |
//|         count     - number of elements to copy,                  |
//|         buffer    - reference to a dynamic array of double       |
//|                     values.                                      |
//| OUTPUT: >=0 if successful, -1 if not.                            |
//| REMARK: no.                                                      |
//+------------------------------------------------------------------+
int CiTime::GetData(int start_pos,int count,datetime& buffer[]) const
  {
   return(CopyTime(m_symbol,m_period,start_pos,count,buffer));
  }


there is another error message, this should be "CiTime::GetData:invalid buffer"

"CiSpread::GetData: invalid buffer"


thrid,

CiTime::GetData(int index)

it doesn't work for me. 


but this method works.

GetData(int start_pos,int count,datetime& buffer[])


is there any different?



thanks,

Reason: