Download MetaTrader 5
To add comments, please log in or register
Take active part in the life of the community. Improve your rating!
winterss
55
winterss 2015.02.28 15:10 

hi, I had working mql4 expert, and after a new build it stopped to work as expected. Current build is 765

Namely, array passed to a function has no values.

 Please see attached full code and of its execution output:

void OnTick()
  {
ArrayResize(listOfLiveMNumbers,10,4);
ArrayResize(listOfStopMNumbers,10,4);
int resNums[][2];
ArrayResize(resNums,0);
      Print("listOfLiveMNumbers");
      ArrayPrintInt(listOfLiveMNumbers);
      Print("listOfStopMNumbers");
      ArrayPrintInt(listOfStopMNumbers);
ArrayMerge(listOfStopMNumbers, listOfLiveMNumbers, resNums);
   
  }
//+------------------------------------------------------------------+


int ArrayMerge(int &stopArray[][], int &liveArray[][], int &resultArray[][])
{
bool isfound=false;
int i=0,j=0,as=0;
if(ArraySize(liveArray)==0 || ArraySize(stopArray)==0) 
   {
      Print("ArrayMerge: both arrays must have values");  
      Print("liveArray");
      ArrayPrintInt(liveArray);
      Print("stopArray");
      ArrayPrintInt(stopArray);
      return(-1);
   }
..............

 

0       15:45:43        2012.01.02 00:00  test EURCHF,M30: listOfLiveMNumbers
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array Size (ArrayPrintInt):20
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array ([0][0]=0,[0][1]=0 ; [1][0]=0,[1][1]=0 ; [2][0]=0,[2][1]=0 ; [3][0]=0,[3][1]=0 ; [4][0]=0,[4][1]=0 ; [5][0]=0,[5][1]=0 ; [6][0]=0,[6][1]=0 ; [7][0]=0,[7][1]=0 ; [8][0]=0,[8][1]=0 ; [9][0]=0,[9][1]=0 ; )
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: listOfStopMNumbers
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array Size (ArrayPrintInt):20
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array ([0][0]=0,[0][1]=0 ; [1][0]=0,[1][1]=0 ; [2][0]=0,[2][1]=0 ; [3][0]=0,[3][1]=0 ; [4][0]=0,[4][1]=0 ; [5][0]=0,[5][1]=0 ; [6][0]=0,[6][1]=0 ; [7][0]=0,[7][1]=0 ; [8][0]=0,[8][1]=0 ; [9][0]=0,[9][1]=0 ; )
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: ArrayMerge: both arrays must have values
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: liveArray
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array Size (ArrayPrintInt):0
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array ()
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: stopArray
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array Size (ArrayPrintInt):0
0       15:45:43        2012.01.02 00:00  test EURCHF,M30: Array ()

 

Files:
test.mq4 4 kb
Carl Schreiber
5932
Carl Schreiber 2015.02.28 18:34  

Your rerNum-array has the size 0,2;

ArrayResize(resNums,0);
Keith Watford
Moderator
7875
Keith Watford 2015.02.28 20:39  
winters:

hi, I had working mql4 expert, and after a new build it stopped to work as expected. Current build is 765

Namely, array passed to a function has no values.

 Please see attached full code and of its execution output:

 

 

The arrays have values,but they are all zero as they are re-sized but not assigned any other values.

What your code does show is that when multi-dimensional arrays are passed by reference to a function, ArraySize() doesn't seem to work.

ArrayRange() does work though. 

winterss
55
winterss 2015.03.01 16:55  
GumRai:

The arrays have values,but they are all zero as they are re-sized but not assigned any other values.

What your code does show is that when multi-dimensional arrays are passed by reference to a function, ArraySize() doesn't seem to work.

ArrayRange() does work though. 

 

 

Thank you! 

/
To add comments, please log in or register