If you resize a local array, does it stay the same size after exiting function?!
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 }
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!