Last 15 minutes of TICK data maintained in array - How can I do it?

 

The main problem I have is figuring out how many ticks there are before resizing the array.


int duration=900; //15 minutes

Do

{

    for (int i=arraySize-1; i>1; i--)

    {

     array[i]=array[i-1];

    } 

}

while(currentTickTime < firstTickTime  + duration )


I am just stumped!!!

 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2.  for (int i=arraySize-1; i>1; i--) array[i]=array[i-1];
    No need to keep moving values and then updating array[0] (which your code doesn't do), just add the last to the enlarged array.
  3. xazarlx20: The main problem I have is figuring out how many ticks there are before resizing the array. I am just stumped!!!

    Perhaps you should read the manual. ArraySize/ArrayResize. You start with zero size, enlarge it by one for each tick. The size of the array is “how many ticks there are before.”
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code properly in a new post.
 
SymbolInfoTick(_Symbol,currentTick);
int i=ArraySize(ticks);
while(--i > 0 && ticks[i].time + duration < currentTick.time);
ArrayResize(++i + 1);
while(--i >= 0)
  {
   ticks[i+1]=ticks[i];
  }
ticks[0]=currentTick;

Assuming you need an array of tick structs ordered newest first.

 
lippmaje: Assuming you need an array of tick structs ordered newest first.

Moving ticks up is unnecessary, even if you want that.

int i=ArraySize(ticks);
ArraySetAsSeries(ticks,false);
ArrayResize(ticks, i + 1);
ArraySetAsSeries(ticks,true);
ticks[0]=…;