Resize Timeseries Array

 

Hi every one,

I defined an Array , then set it as a timeseries, then resize it ! 

As mentioned in the document it should serve as a reverse index Array but when I resize it , new allocated memory index is at the end instead of at the beginning!

is it normal?

is there any way, function or ETC. to do what I will?

or I should hopelessly advise a method to do so?

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart() {

   ArraySetAsSeries(logH,false);
   Print("array size: ",ArraySize(logH));
   ArrayResize(logH, 2);
   logH[0] = 1;
   logH[1]=2;
   ArrayResize(logH, 3);
   for(int i = 0 ; i< ArraySize(logH); i++) {
      Print(i, " : ",logH[i]);
   }
}
//+------------------------------------------------------------------+
//result is : 
 2 : 0.0
 1 : 2.0
 0 : 1.0
 array size: 0
 
  1. Gholamhossein Eslamizadeh: is it normal?

    MTx has always worked like that. You are enlarging the array adding addition elements at the end.

  2. Gholamhossein Eslamizadeh: is there any way, function or ETC. to do what I will?

    You haven't stated what you want.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  3. If you want to add an element at zero and move all existing elements higher; set non-series, increase the size, set as-series.
 
Gholamhossein Eslamizadeh:

I defined an Array , then set it as a timeseries, then resize it ! 

No, you don't.

ArraySetAsSeries(logH,false);
 
William Roeder:
  1. set non-series, increase the size, set as-series.

thanks, it worked. 

Does this method slow my code? 

Do you think using  ( ArraySize(Array) - index) to reverse index is faster?

 
Keith Watford:

No, you don't.

My bad, I change code many times and I just forgot to set it back to true ....