Magically array size?!

 

Why does an empty dynamic array, on a 1 day EA with a 5m timeframe produce > 80k element with this code? 
Is it always linked to the amount of bars on the chart? Because I don't want that. I just need the Series functionality to catch the latest 3 zigzag values. 

 

// I've set my_array[] on top and ArraySetAsSeries(my_array, true) in the Init function of an expert adviser

Print("Array Size: ", ArraySize(my_array));
ArrayResize(my_array, ArraySize(my_array) + 1);
Print("Array Size: ", ArraySize(my_array));

 

This produces:

2016.08.18 22:52:49.590 2016.08.03 23:56  NQ 123 Expert EURUSD,M5: Array Size: 82841
2016.08.18 22:52:49.590 2016.08.03 23:56  NQ 123 Expert EURUSD,M5: Array Size: 82840
2016.08.18 22:52:49.590 2016.08.03 23:55  NQ 123 Expert EURUSD,M5: Array Size: 82840
2016.08.18 22:52:49.589 2016.08.03 23:55  NQ 123 Expert EURUSD,M5: Array Size: 82839
2016.08.18 22:52:49.463 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82043
2016.08.18 22:52:49.462 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82042
2016.08.18 22:52:49.462 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82042
2016.08.18 22:52:49.462 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82041
2016.08.18 22:52:49.461 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82041
2016.08.18 22:52:49.461 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82040
2016.08.18 22:52:49.461 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82040
2016.08.18 22:52:49.461 2016.08.03 23:29  NQ 123 Expert EURUSD,M5: Array Size: 82039


Yes, it really starts at 82039..
 

The OnTick() Event Handler gets called on every Tick (just as the name says) and NOT on every M5 bar, just because it is on a M5 Chart.

For example, if given that there is an average VOLUME of 300 ticks per M5 bar (and that there are 12 M5 bars per hour), then that would give 24hr x 12 x 300 ticks = 86400 ticks per day.

Therefore, if you increment the size of your array on every tick, obviously it will have 86400 elements within a period of 24 hours and will continue to grow, and is in no way linked to the number of Bars on the Chart.

 
FMIC:

The OnTick() Event Handler gets called on every Tick (just as the name says) and NOT on every M5 bar, just because it is on a M5 Chart.

For example, if given that there is an average VOLUME of 300 ticks per M5 bar (and that there are 12 M5 bars per hour), then that would give 24hr x 12 x 300 ticks = 86400 ticks per day.

Therefore, if you increment the size of your array on every tick, obviously it will have 86400 elements within a period of 24 hours and will continue to grow, and is in no way linked to the number of Bars on the Chart.

Aha, thanks.
Reason: