what's the size of a 2d array delimiter?

 

hi,

I'm passing a 2d array to a c++ dll.
To simplify the example the will speak about RateInfo serries obtain by calling ArrayCopyRates.
Then i extract only one serrie in a simple array:

double h2[6];

and i use

setprecision(10)
for the "ctm" (time) value, all is ok.
But if i pass a 2d array some returned value is ok, and other is like this:
-1.0019e+191
end at the end i obtain serries of
n x 6(0):

0
0
0
0
0
0

0
0
0
0
0
0

So i conclued than there is a delimiter, or a "hidden" element in the array.
Did someone know that is the type or the size of this delimiter/element??

 

funny: the method what's working:

  double h1[][6];
  double hff[][6];

  ArrayCopyRates(h1);
  
  ArrayResize(hff,Bars);
  ArrayCopy(hff,h1,0,0); 

  exportdoublearr(hff, Bars);
Don't know why, but it's ok. just the array is inverted..
 

the rateinfo array is not a normal 2d array, it is something special. it contains doubles and integers mixed, so it is in reality better represented as something like this:


(Pascal code)

type
  { MT4 stores the data of each candle in such a structure.
  MT4 will then give us a pointer to an array of such candles.
  NOTE the unconventional order: open, low, high, close, volume
  instead of OHLCV }
  PCandle = ^TCandle;
  TCandle = packed record
    time:   LongInt; // POSIX timestamp
    open,
    low,
    high,
    close,
    volume: double;
  end;

(this would be a struct in C++)

and then you would use an array of these records (or structs). MT4 will pass a pointer to the first element (oldest bar!) of this. There is no delimiter, the values lie in memory direcly one after the other. You should really read this: http://www.forexfactory.com/showthread.php?t=219576


I am teaching this in Pascal rather than in C++ because the concepts needed to be understood are better (more clearly) expressed and visualized in Pascal. The structures and the concepts are the same as in C++, they just become more "visible", more clear when presented in this language.

 

Please check exapmle "..experts\samples\DLLSample\ExpertSample.cpp" in your MT4.

Second dimension of array is defined as struct:

struct RateInfo
  {
   unsigned int      ctm;
   double            open;
   double            low;
   double            high;
   double            close;
   double            vol;
  };
Reason: