Why in the world can't I initialize a multidimensional array with variables? - page 2

 
trevor88 #: I can access my data... the only thing I can't do is create a multidimensional array automatically. I have to type the values.

The solution in post #3 is indeed the best option!

Create a class that uses a simple single dimensional array as the data storage, and then overload the [] operator to translate the multidimensional coordinates. In the class constructor or an initialisation method, you can then set the sizes of each dimension dynamically, and allocate the necessary storage accordingly.

You can also use templates to declare classes for different data-types besides "double".

Also, have a look at the latest MQL5 functionality for using matrices. It may be useful for what you want to achieve.

 
You could use the matrix type.
Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
Documentation on MQL5: Language Basics / Data Types / Matrices and vectors
  • www.mql5.com
Matrices and vectors - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: