Is there some more information on array classes?

 

Hello,

is there any more information on how to use the CArrayDouble for example or is the exampe given in the CArrayObj
https://www.mql5.com/en/docs/standardlibrary/datastructures/carrayobj the only explaination on the topic? I am not getting it.

If I declare an object of CArrayDouble

CArrayDouble   *array_double;

// then I can say

array_double.Resize(10) ;   // to set ArraySize to 10

// and to get the values

array_double.At(0)  // respective 1,2,...,9;

that doesn't seem to be possible with CHighBuffer though which should be an inheritant of CDoubleBuffer which is an inheritant of CArrayDouble. Does certain inheritance get lost after a few generations?

Then I am trying to fill the array with values, so I am doing some

CiHigh  high;

//... (OnInit)

high.Resize(10);

//... (OnTick)

high.GetData(0,9,high);

here, unfortunately I get an overloads compilytion error with GetData because it needs an array of the form high[] but this means that each element of the [] array is an object of the CiHigh class and then high[0,1,...,n].Resize() doesn't make any sense, so I can only work with

ArrayResize(high,10,0)

In case you asked yourself: I am trying to imagine the standard functions built back to the classes because I was thinking that it has to become conclusive at some point, but now I am more riddled than before. So is there an article about this?

If not I will help myself with this article https://www.mql5.com/en/articles/351

Still I am not convinced that these ends don't meet.

The Basics of Object-Oriented Programming
The Basics of Object-Oriented Programming
  • www.mql5.com
You don't need to know what are polymorphism, encapsulation, etc. all about in to use object-oriented programming (OOP)... you may simply use these features. This article covers the basics of OOP with hands-on examples.
 
pennyhunter:

Hello,

is there any more information on how to use the CArrayDouble for example or is the exampe given in the CArrayObj
https://www.mql5.com/en/docs/standardlibrary/datastructures/carrayobj the only explaination on the topic? I am not getting it.

If I declare an object of CArrayDouble

that doesn't seem to be possible with CHighBuffer though which should be an inheritant of CDoubleBuffer which is an inheritant of CArrayDouble. Does certain inheritance get lost after a few generations?

Then I am trying to fill the array with values, so I am doing some

here, unfortunately I get an overloads compilytion error with GetData because it needs an array of the form high[] but this means that each element of the [] array is an object of the CiHigh class and then high[0,1,...,n].Resize() doesn't make any sense, so I can only work with

In case you asked yourself: I am trying to imagine the standard functions built back to the classes because I was thinking that it has to become conclusive at some point, but now I am more riddled than before. So is there an article about this?

If not I will help myself with this article https://www.mql5.com/en/articles/351

Still I am not convinced that these ends don't meet.

As far as I know the documentation is not very clear on these classes, it's better to look at the source code. For the CiHigh GetData has the following signatures:

   double            GetData(const int index) const { return(CPriceSeries::GetData(index)); }
   int               GetData(const int start_pos,const int count,double &buffer[]) const;
   int               GetData(const datetime start_time,const int count,double &buffer[]) const;
   int               GetData(const datetime start_time,const datetime stop_time,double &buffer[]) const;

The first one allows you to get a single value at a time.

The second one you are trying to use, is to get multiple values into a "double x[]" array, not the CiHigh object.
So you don't pass high again like you did, you are confusing "arrays declared with []" with the "class array".

An alternative instead of using this class is to use the function CopyHigh which is what it uses in its implementation
and it is a lot simpler.

Documentation on MQL5: Timeseries and Indicators Access / CopyHigh
Documentation on MQL5: Timeseries and Indicators Access / CopyHigh
  • www.mql5.com
CopyHigh - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5