Max count for a array index

 

i want to create a walking FILO ( first in, last out ) time buffer where i use the symbol timestamp as array index value.  Does anyone know if there is any impact of performance using a 14 count array index value ?

Example

foo[1518776791280] = 1;
foo[1518776791282] = 1;
foo[1518776791283] = 1;


Or i substr the first 5 integer and limit the max array size to 9. Guess i will never have 9,9Mio values in a array.

But i guess, this is easier as to copy the entire array ( -1 item ) into a new array and add the new element.When i use the copy method i also have the create a seperate matching array for time reference of this values. With this solution i can save code and memory, so far it is working.

What do you think ?

 
Christian Stern: limit the max array size to 9.
foo[1518776791280] = 1;

Those two are contradictory. If foo is a int array (4 bytes per element) your array is 5.6 GB in size. You'll need twice that must RAM for a copy. Better rethink what you're trying to do.

 

no :D i dont have a SPARC T5 at home .... you misunderstood it. I want a walking time index for a value x. The timestamp has 14 counts integer, where i actuelly just need the first 9 integer.


The array will start like at timestamp 1518776791280:

foo[1518776791280] = 1;

And the end of the array would be 60 sec later.

Each time i add a new value, a old value will be deleted. 

My question is, can i create a array with a starting index id which is 9 || 14 integer long ? Is there any limitation of the index ?


Or is there a better way of creating a walking array ? I don't want to copy the entire array each time i add a new value.

 
  1. Don't double post!
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Christian Stern: The array will start like at timestamp 1518776791280:

    What part of it can't was unclear?

    Marco vd Heijden: Total amount of elements in the array cannot exceed 2147483647.

  3. Christian Stern: And the end of the array would be 60 sec later.
    Use the second part of the timestamp
 
https://www.mql5.com/en/articles/3047
MQL5 Cookbook - Creating a ring buffer for fast calculation of indicators in a sliding window
MQL5 Cookbook - Creating a ring buffer for fast calculation of indicators in a sliding window
  • 2017.06.07
  • Vasiliy Sokolov
  • www.mql5.com
Most calculations performed by traders are conducted in a sliding window. This happens due to the very nature of market data which almost always arrive in a continuous stream regardless of whether we deal with prices, bids or trading volumes. Typically, a trader needs to calculate a value for a certain period of time. For example, if we...
 
nicholishen:
https://www.mql5.com/en/articles/3047

@nicholishen -> ur my hero :D thank you

I knew the articel but never had a closer look. Now, until i can define what i want, i have a different view to this articel and i found a easy ( way too easy) cpu/memory saving way to have a bunch of ring buffers.

Reason: