![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
If you want a non-dynamic array you have to make sure to specify exactly the same number of elements that's used in the initializer list, otherwise you'll get this error.
To avoid that hassle I suggest to always go with dynamic arrays when it comes to initialize it by a list.
The advantage is that you don't have to count your initializers and adapt that array size everytime you change that list.
The disadvantage is that a dynamic array uses up more memory - 52 bytes - for the dynamic array properties. I guess you can live with this in most of the cases.
Thanks for detailed explanation lippmaje.
Well while making it static, defining ArrayResize was the problem in my mind (as I did not knew, how I will for a member Array).
now explanation has made everything crystal clear.
Thanks a lot once again.
Hi lippmaje
Can you suggest some structure and how to fill it & call it. The object is to store static Camarilla Pivot Levels (R5,R4,R3,R2,R1,PP,S1,S2,S3,S4 and S5) and change dynamically level values every new day start.
In simple language, I am looking to create Column[1] as List of Pivot Levels (to be able to select level) and Colum[2] for 'level values' which shall change everyday. No need to keep history data.
It is some how similar to Fibonacci structure we used above, but I am finding difficult to handle string values of PivotLevels.
Thanks in advance for you support and help.
You didn't declare your constructor in the class.
The initialization list only works when you declare an array. You can not use it at runtime.
Hi William
I have a similar problem, and wish to follow your second option but am getting stuck at the missing default value for the passed array:
Please help! The class is to enable the representation of an array of boolean values as a decimal (via binary) number for optimisation of large (variable) numbers of boolean parameters
You can't default a reference. Arrays must be passed by reference. Write two constructors.
I am so sorry, but I do not understand your last sentance - the first I suspected, the second I knew. But I still do not understand how to make this code reusable in terms of being able to define a class array without defining a global array prior to instantiating the object and iterating through it in the constructor... or is this what you meant i.e.
also, should the Init declaration start with
or
given that default values are given in the declaration of the constructor... I suppose they should remain in the Init declaration to allow reuse of the function after the Class instance is loaded?
Andrew Thompson #: I am so sorry, but I do not understand your last sentance - t