double blah[]; int arrayLength = 10; ArrayResize(blah,arrayLength);ArrayResize() is the only solution for MT4.
Ahh I see, thankyou kolier. Your answer is much appreciated!
Cheers,
Seb
All arrays in MQL4 are static, hence they can only be initialized with a constant.
a compromise might be
#define mysize 10 double arr[mysize];
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey guys,
Brand new to MQL4, been reading the docs and all that, so go easy on me!
Just wondering if its possible to initialize an array with a variable length.
For instance, the following works fine:
double blah[10];
...Whereas this doesn't':
int arrayLength = 10;
double blah[arrayLength];
..returning: "integer number expected".
It seems to me that it should be trivial for MQL to support inheriting an array length via an integer variable, so I'm not sure why this behavior is present?
Kind regards,
Seb