How copy to the second dimension of multi-dimension array

 

Please help

How to copy from one dimension array directly into the second dimension array of multi-dimension array, without using looping ??

Or is it possible to copybuffer from indicator result into the second dimension of multi-dimension array ??

Thank you

 

Make a struct, that you can copy other than an array:

void OnStart()
  {
  int i0,i1,i2;
  struct ar {
     int a[3][5]; //[7]; // 2- //3-dimensional dynamic array
  } arr1, arr2;

  for(i0=0;i0<ArrayRange(arr1.a,0);i0++) {
      for(i1=0;i1<ArrayRange(arr1.a,1);i1++) {
         //for(i2=0;i2<ArrayRange(arr1.a,2);i2++) {
            arr1.a[i0][i1] = 6; //[i2] = 7;
  }   }  //}
  ArrayPrint(arr1.a);
  arr2 = arr1;
  ArrayPrint(arr2.a);
  
  }
//+------------------------------------------------------------------+

ArrayPrint does not work on 3 dim arrays...

But do you need one dim. Arrays? If you use matrices (2-dim) you can easily 'extract' a row or a column as vector (1-dim), see: https://www.mql5.com/en/docs/matrix/matrix_manipulations

Documentation on MQL5: Matrix and Vector Methods / Manipulations
Documentation on MQL5: Matrix and Vector Methods / Manipulations
  • www.mql5.com
These are methods for basic matrix operations: filling, copying, getting a part of a matrix, transposing, splitting and sorting. There are also...