ArrayCopyRates Bug or Documentation Error?

 

I'm getting confused with the function ArrayCopyRates. I haven't been getting the results I expected from it so I wrote a dumped out the contents and either it has a bug or the documentation is wrong???


double aRates[][6];
ArrayCopyRates(aRates);


For instance this is a dump of my first few elements (done via a DLL not MT4):

[0,0]=0.00
[0,1]=0.00
[0,2]=0.00
[0,3]=0.00
[0,4]=0.00
[0,5]=1.42673691785554912E51 <-- Time
[1,0]=1.51 <-- Open
[1,1]=1.51 <-- Low
[1,2]=1.52 <-- High
[1,3]=1.52 <-- Close
[1,4]=680.00 <-- Volume
[1,5]=0.00
[2,0]=0.00
[2,1]=-3.49189614868057216E151
[2,2]=0.00
[2,3]=0.00
[2,4]=1.42802144085112448E51 <-- Time
[2,5]=1.52 <-- Open
[3,0]=1.52 <-- Low
[3,1]=1.52 <-- High
[3,2]=1.52 <-- Close
[3,3]=1004.00 <-- Volume
[3,4]=0.00
[3,5]=3.87223119825409984E307


According the to documentation it's supposed to have 6 elements in the second dimension but looking at the output it looks like 11.


Have I misunderstood something here or is this a bug or documentation error?


Thanks

 

Document says:

"Memory is not really allocated for data array, and no real copying is performed. When such an array is accessed, the access will be redirected. "

maybe the DLL doesn't trigger the redirect.

 

I think that's talking about the access in MT4 which does act differently. i.e. it shows 6 elements and the data looks ok. From a DLL it looks totally different. I can pass other multi-dimension arrays ok it just this one that acts odd. I probably need to play around with the array which is created by the function...

 
sparkz:

I think that's talking about the access in MT4 which does act differently. i.e. it shows 6 elements and the data looks ok. From a DLL it looks totally different. I can pass other multi-dimension arrays ok it just this one that acts odd. I probably need to play around with the array which is created by the function...

I got to the bottom of it. I would say the documentation is lacking somewhat.


Although in MT4 what you get appears to be an array of 6 double elements, in a DLL what you get is an address to an array of records. Each record contains:


Time - integer (4 bytes)

Open - double

Low - double

High - double

Close - double

Volume - double


So the time field throws it all out if you're trying to access it as double [][6] . It would handy if they actually mentioned this in the documentation!

Reason: