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
ok lets try the english version of MQL.
Thanks for your code post. It saved me time. I tried using the MQL arrays and they were confusing. I then was very depressed that I need to once again need to write basic structures that was supposed to be there BUT then I found your code that saved me some research time on arrays and how to make them grow\increase dynamically. AWESOME thanks.
I hope i can give back to you! the code below works for all data types. It will work on objects too but the Contains (search) method might not work. I only tested it on types (double, int, bool). String might give you problem as well and the code might need to be extended.
Then you can declare it for all types you need like so:
hope this helps anyone
Please disregard my suggestion above to use the Dynamic array for any data type. There is already a generic CArrayList declared. please use this. I encountered a problem using objects that was resolved on this thread: https://www.mql5.com/en/forum/358432
It seems a error in the function arrayResize(), in the example the content of the array is 1, 1, 3 in normal indexing not 1, 2, 3. See this example:
In added the function arraySetAsSeries() it seems be affected by function arrayresieze, se this example:Steps:
1. ar = {}
2. ar = {9, 8}
3. ar = {9, 8, 0, 8, 0, 0}
4. Set as series true:
ar = {0, 0, 8, 0, 8, 9}
5. Resize to 4
ar = {0, 0, 8, 0}
6. Set as series false:
ar = {0, 8, 0, 0}
7. Set as series true:
ar = {0, 0, 8, 0}
8. Modify the first element a[0]
ar = {8, 0, 8, 0}
I don't know what array resize (3 -5) takes the values and copy in the new positions, 6 in forward takes random values, I think. I prefer resize() first and then setasseries() like this: