Using Array of Arrays

 

I'm trying to create & use an array of arrays, and got stuck.

   //// note that StatsTally will resize pStatHolder to particular size
   //int StatsTally(double pTallyValue, double& pStatHolder[]);   
   double Arr[];
   double ArrOfArr1[169][];
   double ArrOfArr2[][];

   ArrayResize(Arr, 5);
   StatsTally(1.2, Arr); // works

   ArrayResize(ArrOfArr2, 169);  // works
   ArrayResize(ArrOfArr1[0], 5); // fails with ',' - wrong dimension    
   ArrayResize(ArrOfArr2[0], 5); // fails with ',' - wrong dimension    
   StatsTally(1.2, ArrOfArr1[0]); // fails with 'ArrOfArr1' - incompatible types
   StatsTally(1.2, ArrOfArr2[0]); // fails with 'ArrOfArr2' - incompatible types

If anyone can point me in the right direction on how to use a (dynamic or fixed) array of (single dimensional dynamic array), I would appreciate it.

(I've searched for 'array of arrays' here & not found anything suitable)

 

for array of array, you only can :

double array1[][4]; // should fix 2nd dimension size
ArrayResize(array1, 20); //set 1st dimension size

Since ArrayResize(...) of MQL only can be used for setting 1st dimension size !

https://docs.mql4.com/array/ArrayResize

 
Hmmm. thanks for that. I'll have to rethink my storage strategy. maybe not have StatsTally resize array if needed.
 

Should anyone be interested, I fixed it by coding:

int Stats.Tally(double pTallyValue, double& pStatHolder[], int pStartIx);
...
double AllHrStats[]; // 169th = weekly gap
...
   StatsSz = Stats.Size();  // = 3
   ArrayResize(AllHrStats, 169*StatsSz);
...
   for(int iHr=0; iHr<168; iHr++)
      {
         ...
         double tr = MathMax(H, PC) - MathMin(L, PC);
         Stats.Tally(tr, AllHrStats, iHr*StatsSz);
      }
...
   for(iHr=0; iHr<168; iHr++)
   {
      int N = Stats.N(AllHrStats, iHr*StatsSz);
      if(N == 0)
         continue;
      double Avg = Stats.Avg(AllHrStats, iHr*StatsSz);
      double SD = Stats.StdDev(AllHrStats, iHr*StatsSz);
      Print("iHr=", iHr, ", N=", N, ", Avg=", DoubleToStr(Avg, 5), " SD=", DoubleToStr(SD, 5));
   }
Reason: