Download MetaTrader 5

Array won't update

To add comments, please log in or register
nadiawicket
397
nadiawicket  
   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 ?

Ex Ovo Omnia
3341
Ex Ovo Omnia  
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--)
nadiawicket
397
nadiawicket  
Ex Ovo Omnia:


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

Thx. Anything else?
JC
1514
JC  
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.
Ex Ovo Omnia
3341
Ex Ovo Omnia  
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.
nadiawicket
397
nadiawicket  
Got it down, just needed to stick to basics.
To add comments, please log in or register