Doesn't look like you initialized the values of the array.
Typically in C and C++ when you create an array or use the resize it doesn't automatically initialize the elements to 0. You are simply creating pointers in memory, so whatever value those pointers happen to point to on the heap is the result you will get.
After you declare and resize the arrays you should initialize them to 0 if that is your expectation for those arrays. This isn't always necessary, especially if you are just planning to explicitly set the values later.
That's a plausible explanation, but after a system restart (memory is empty), I got the very same result. I even tried on a different computer, different OS, but it's the same.
Ok, that is really strange and definitely looks like a bug. Just gave it a try and validated your EXACT results. Definitely something strange going on in the ArrayResize the good news is you can just use the ArrayInitialize function to put things right.
ArrayInitialize(arrayA,0); ArrayInitialize(arrayB,0.0);
- www.mql5.com
What the bug you are talking about?
Where is ArrayInitialize in your code?
Please read documentation https://www.mql5.com/en/docs/basis/variables/initialization
If a variable is not initialized explicitly, the value stored in this variable can be any
- www.mql5.com
What the bug you are talking about?
Where is ArrayInitialize in your code?
Please read documentation https://www.mql5.com/en/docs/basis/variables/initialization
Thanks @stringo. I agree Array initialization should be used, but it is still strange that the results after using ArrayResize are consistent across machines when using the uninitialized arrays.
According to the documentation you referenced it isn't a bug, but could definitely be confusing when encountered.
- www.mql5.com
Thanks @stringo. I agree Array initialization should be used, but it is still strange that the results after using ArrayResize are consistent across machines when using the uninitialized arrays.
According to the documentation you referenced it isn't a bug, but could definitely be confusing when encountered.
Than are dreamt of in your philosophy. (c) Hamlet, Prince of Denmark
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When I do, I always get this output: