Bug in ArrayIsSeries?

 

Hello, I created a custom indicator in MQL5 (version 5.00 build 3802) that uses the functions ArraySetAsSeries and ArrayIsSeries to handle array indexing as timeseries. After some tests I think that ArrayIsSeries is buggy. I took the official code from the MQL5 documentation for ArraySetAsSeries (https://www.mql5.com/en/docs/array/arraysetasseries) and modified it a bit to do some tests.

int OnCalculate(const int rates_total, 
                const int prev_calculated, 
                const datetime &time[], 
                const double &open[], 
                const double &high[], 
                const double &low[], 
                const double &close[], 
                const long &tick_volume[], 
                const long &volume[], 
                const int &spread[]) 
  { 
//---  nous stockerons l'heure d'ouverture de la barre zéro courante 
   static datetime currentBarTimeOpen=0; 
//--- renverse l'accès au tableau time[] - mettons le comme dans les timeseries 


   ArraySetAsSeries(time,true); 
   Print( "time");
   Print ( ArrayIsSeries( time));
   Print ( ArrayGetAsSeries( time));
   ArrayPrint(time);
   
   Print( "arrayTmp");
   datetime  arrayTmp[]; 
   ArraySetAsSeries(arrayTmp, true);
   ArrayCopy( arrayTmp, time, 0, WHOLE_ARRAY);
   Print ( ArrayIsSeries( arrayTmp));
   Print ( ArrayGetAsSeries( arrayTmp));
   ArrayPrint(arrayTmp);

The result is not convincing, we can see that ArrayIsSeries works on system constants, but not on non-system arrays, in the outputs of the prints:

time
true
true
[  0] 2023.05.31 00:00:00 2023.05.30 00:00:00 2023.05.29 00:00:00 2023.05.26 00:00:00 2023.05.25 00:00:00 2023.05.24 00:00:00 2023.05.23 00:00:00

arrayTmp
false
true
[  0] 2023.05.31 00:00:00 2023.05.30 00:00:00 2023.05.29 00:00:00 2023.05.26 00:00:00 2023.05.25 00:00:00 2023.05.24 00:00:00 2023.05.23 00:00:00

On the other hand, arraysGetAsseries works. I expected the function ArrayIsSeries to return true for the arrayTmp array which is clearly a timeseries, because it contains data ordered by time and it has the AS_SERIES flag set to true. Please let me know if this is a bug, thank you.

 
William210:

Hello, I created a custom indicator in MQL5 (version 5.00 build 3802) that uses the functions ArraySetAsSeries and ArrayIsSeries to handle array indexing as timeseries. After some tests I think that ArrayIsSeries is buggy. I took the official code from the MQL5 documentation for ArraySetAsSeries (https://www.mql5.com/en/docs/array/arraysetasseries) and modified it a bit to do some tests.


The result is not convincing, we can see that ArrayIsSeries works on system constants, but not on non-system arrays, in the outputs of the prints:

On the other hand, arraysGetAsseries works. I expected the function ArrayIsSeries to return true for the arrayTmp array which is clearly a timeseries, because it contains data ordered by time and it has the AS_SERIES flag set to true. Please let me know if this is a bug, thank you.

No, ArrayIsSeries and ArrayGetSeries do two different things.

ArrayIsSeries will inform you about an array being managed by the Terminal. While ArrayGetSeries will inform you about the Flag for an array.

They do two fundamentally different things.

Your printout shows correct results.

 
Thanks 
Reason: