array size allocation depending on variable

 
Hi everyone,
I am new in MQL4, and I had a simple question for you:

I'd like to size (allocate a given size to) a global array of uint depending on the result of a previous calculation.
Actually I'm trying to make a robot on which the user sets a given time interval, let's say 10 seconds, but could be 1 minute, 2 hours, 5 days, ...

For example:

extern uint g_UserTimeInterval_secs = 150; // user interval in seconds
uint g_numberofelements = g_UserTimeInterval_secs/1e-3; // as my reference unit time is 1ms
uint g_ticksvalues[g_numberofelements] = { 0 }; // <--- This is where I want so size my array depending on the previous line


int OnInit()

{

...



How can I do that?
Thanks in advance for your answers.
François
 
ArrayResize() is you friend. But study the example there.
Documentation on MQL5: Array Functions / ArrayResize
Documentation on MQL5: Array Functions / ArrayResize
  • www.mql5.com
If ArrayResize() is applied to a static array, a timeseries or an indicator buffer, the array size remains the same – these arrays will not be reallocated. In this case, if The function can be applied only to dynamic arrays. It should be noted that you cannot change the size of dynamic arrays assigned as indicator buffers by the...
 
Carl Schreiber:
ArrayResize() is you friend. But study the example there.
Thanks a lot Carl !