Hello!
is there a quick and nice way to get the index of the last element in an array or the index of the first empty value?
One way of course would be the use of an index variable but maybe there is a better way.
I also tried ArraySize but I initialize my Arrays at the beginning with a size of i.e. 10 and even though the array still does not contain any values, ArraySize returns 10 and not 0 or NULL.
Any ideas?
A dynamic array will give you the total count of elements through a single method call.
https://www.mql5.com/en/docs/standardlibrary/datastructures/carray/carraytotal
For fixed arrays, I know of no "nice easy" way. Maybe loop backwards from the end or remember the value as you suggested.
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
is there a quick and nice way to get the index of the last element in an array or the index of the first empty value?
One way of course would be the use of an index variable but maybe there is a better way.
I also tried ArraySize but I initialize my Arrays at the beginning with a size of i.e. 10 and even though the array still does not contain any values, ArraySize returns 10 and not 0 or NULL.
Any ideas?