Dynamically sized arrays?
datetime events[];
ArrayResize(events, totalEvents);
Thanks! Out of curiosity, how expensive is that ArrayResize() function?
If you're wanting to keep resizing an array, I would suggest that you re-evaluate your logic, especially of array keeps getting larger.
Array techniques I use are:
- if say varying from 5 to 10, then fix size at 10 but use another variable for size. e.g. double MyArray[10] & int MyArraySize = 7;
- if 'all historical values' then use say double MyHistory[100] and treat it as circular buffer, actually just holding 'last 100 values'
(for circular buffer, either use 'circular index' or else 'shuffle entries & drop oldest' as you add next value )
Hi,
How do you create a dynamically sized array in mql4? Is there a *new* construct? I can't even use a variable to define the array size:
int totalEvents = 7;
datetime events[totalEvents];
:(