error on Tester: incorrect start position 0 for ArraySort function

 

Hello,

when I run the following code it works as supposed to with no errors, but when I back test it ,it creates the error (incorrect start position 0 for ArraySort function)

void OnInit()
  {
  
   int ct = 50;
   long eaHistoryArr[][2];
   ArrayResize(eaHistoryArr, ct);
   
      ArrayInitialize(eaHistoryArr,0);

   
   int xxx=0;
   for (int i = 0; i < 20; i++) {
      if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
                 if(OrderMagicNumber() == 123456){
          eaHistoryArr[i][0] = OrderCloseTime();
          eaHistoryArr[i][1] = OrderTicket();
                    xxx++;
                 }
      }
   }
Alert (1);
   ArraySort(eaHistoryArr,WHOLE_ARRAY,0,MODE_DESCEND);
Alert (2);

   ArrayResize(eaHistoryArr, xxx);
   ArraySort(eaHistoryArr);
Alert (3);

   
   
/*
   Alert(xxx);
   
   ArrayResize(eaHistoryArr, xxx);
*/

//   int arrSize = ArraySize(eaHistoryArr)/2;
   int arrSize = ArrayRange(eaHistoryArr,0);
   
   
   
   Alert(arrSize);
   
   for (int ii = 0; ii < arrSize; ii++) {
   
        Alert (eaHistoryArr[ii][0], "--" ,eaHistoryArr[ii][1]);
   }
   
  }


the tester's Journal:

2020.09.29 00:05:28.478 EURUSD.,M15: 141759 tick events (96 bars, 142759 bar states) processed in 0:00:00.047 (total time 0:00:02.125)

2020.09.29 00:05:28.454 2020.06.19 00:00:00  testtest EURUSD.,M15: Alert: 0

2020.09.29 00:05:28.454 2020.06.19 00:00:00  testtest EURUSD.,M15: Alert: 3

2020.09.29 00:05:28.454 2020.06.19 00:00:00  testtest EURUSD.,M15: incorrect start position 0 for ArraySort function

2020.09.29 00:05:28.454 2020.06.19 00:00:00  testtest EURUSD.,M15: Alert: 2

2020.09.29 00:05:28.454 2020.06.19 00:00:00  testtest EURUSD.,M15: Alert: 1

2020.09.29 00:05:28.430 2020.06.19 00:00:00  testtest test started

2020.09.29 00:05:28.407 TestGenerator: unmatched data error (volume limit 3584 at 2020.06.19 18:30 exceeded)

2020.09.29 00:05:26.355 TestGenerator: spread set to 20

2020.09.29 00:05:26.350 Expert testtest EURUSD.,M15: loaded successfully


why does this error happen? and what does it mean ? and why does it only happen on back testing?

thank you

 
   ArrayResize(eaHistoryArr, xxx);
   ArraySort(eaHistoryArr)

Don't try to sort the array if its size is 0.

 
Keith Watford:

Don't try to sort the array if its size is 0.

yes! thank you 
this was it