Oops... Never Mind!!!
This was actually mentioned in the function description: https://docs.mql4.com/array/ArrayResize/
QUOTE: "Note: Array declared at a local level in a function and resized will remain unchanged after the function has completed its operation. After the function has been recalled, such array will have a size differing from the declared one."
you can avoid this by always resetting an array after declaration.
int myfunc() { int values[]; ArrayResize(values, 0) // size(values) is always 0 }
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
Something really strange is happening:
So in the above example, the Array was re-sized on the local function level inside the 'while' loop. Whatever it's *new size* currently is, I was under the impression that once the function housing the Array exits, the array would then be discarded and then re-initialized anew each time the function was called using:
So the Alert() function here:
Should always return 1, right after the function was defined.
And yet when I run this code, it returns results in the thousands of elements (even though I have double checked the code inside 'while' loop and it only increases the array size by 2-3 elements at a time).
So does the array maintain it's new size after ArrayResize() has been used, even when it is a local Array and not a Global one?!
Thanks!