Array won't update

 
   double tickarray[10];
   static int cnt=9;
   if(cnt<0)
      cnt=0;
   if(tickarray[0]!=0)
     {
      for(int x=10; x>1; x--)
        {
         tickarray[x]=tickarray[x-1];
        }
     }
   tickarray[cnt]=Bid;
   cnt--;
 
   Alert(tickarray[0]);
   Alert(tickarray[1]);
   Alert(tickarray[2]);
   Alert(tickarray[3]);
   Alert(tickarray[4]);
   Alert(tickarray[5]);
   Alert(tickarray[6]);
   Alert(tickarray[7]);
   Alert(tickarray[8]);
   Alert(tickarray[9]);
   Alert(tickarray[10]);
   
  }

I need the 10 last opened order prices in an array, however I'm starting by first gathering the Bid ticks as it seems easier.

The previous code does not allot the values correctly.  I need it to update every array element with the previous ticks so there are the last 10 ticks in the array so I can then compare to another one. Super late tried everything. Any ideas ?

 
nadiawicket:

I need the 10 last opened order prices in an array, however I'm starting by first gathering the Bid ticks as it seems easier.

The previous code does not allot the values correctly.  I need it to update every array element with the previous ticks so there are the last 10 ticks in the array so I can then compare to another one. Super late tried everything. Any ideas ?


I would start with the following idea. Optionally look for ArrayCopy to make the coding easier.

for(int x=10; x>=1; x--)
 
Ex Ovo Omnia:


I would start with the following idea. Optionally look for ArrayCopy to make the coding easier.

Thx. Anything else?
 
nadiawicket:
Thx. Anything else?
Ovo's suggestion of ArrayCopy presumably means something like https://www.mql5.com/en/forum/192882#comment_5070878. Such a use of ArrayCopy isn't guaranteed to work according to the documentation - see notes following link - but does seem to work in practice.
 
nadiawicket:
Thx. Anything else?

You may cycle the array without swapping its values. This is what I would do. But I would suggest to finish the simple idea first.
 
Got it down, just needed to stick to basics.
Reason: