Possible to have a variable for sizing of an array?

 

I am wondering if it is possible to have a variable be one of the parameters to be the size of an array I am using?  I am using the array to hold values of indicators for different periods of time, and want to use an external variable to change the array size in the strategy tester and not the code itself.  Is this correct or do I have to do something else to get this to work?

extern int MinWatch = 30; //30 minutes of back data for now
int n=4*MinWatch; //30 minutes mult by 15 sec  ***currently set to be 120***
static double ADX15minValues[n][4]; //does not want to work, is this possible?
//static double ADX15minValues[120][4]; // this works in the code
 
asham:

I am wondering if it is possible to have a variable be one of the parameters to be the size of an array I am using?  I am using the array to hold values of indicators for different periods of time, and want to use an external variable to change the array size in the strategy tester and not the code itself.  Is this correct or do I have to do something else to get this to work?

Use ArrayResize()
 
RaptorUK:
Use ArrayResize()


Thank you Raptor, I was originally thinking that ArrayResize() was only for changing the size of the array in the middle of the execution (need a few more elements to get the proper calculation).  It worked perfectly for my purposes.
Reason: