I'm new to programming, please help me understand. For example, there is an array in MQL4
double mass[][6]
1. How to pass it into dll in C++?
2. How to display it in a popup window in C++?
When sculpting a working and non-redundant dll, various hassles are too much, so :
-> 1. rearrange the problem so that only one-dimensional arrays need to be passed ("bag-of-tags" way);
-> 2. The basic idea of the dll is that it is a library of functions, i.e. exactly a _calculating_ module, so avoid using any graphical/window elements here at all costs;
-> 3. ( such a point will soon be formed ) : when passing strings, the least headache is when they are ansi-strings, i.e. for Unicode with its subspecies - see item 1. 1, previously converted to char, i.e. bytes, using mql;
-> 4. (If your dll uses objects for calculations, it's better to wrap them in one, get its handle at initialization, pass it to mql-program and then call methods, referring to the wrapper object by this handle.
I think the easiest way for you to implement this is through a file - unload the turkey, load the C++ module and delete it, and so on.
TheXpert:
В MQL4 нет многомерных массивов. Передавайте как одномерный, главное правильно размер высчитать и передать.
I.e. if array[10][6] then its size is one-dimensional 60?
Yes.
So, in C++, you need to create a class that will convert a one-dimensional array back into a two-dimensional one?
Yeah. Sure.
I recently finished writing such a class. It really is a multidimensional dynamic array. I.e. it is possible to change number of measurements on the fly without breaking the data structure.
And also it can be initialized by a pointer to an array. I overloaded the operators. I got 348 overloads :-))
Approximately the same with operators:
a4Arr[1][2][3] += a3Arr[1][0]; // В указанное 4-е измерение массива a4Arr добавляется содержимое 3-го измерения массива a3Arr.I have done mathematical operations and various manipulations for it. There is a reverse for the index and many other things I need to work with.
========================
The array's multidimensionality is just an interface. It can hide an array of arrays, an array of pointers to arrays, an array of container classes, a container class, etc.
In our case, only interpreting a one-dimensional array as a multidimensional one is suitable. Otherwise, there is no way to pass it from MQL4.
i.e. in C++, do you need to create a class that converts a one-dimensional array back to a two-dimensional one?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need to control the state of arrays in my Expert Advisor. For this, I want to create a dll in C++ that would receive two-dimensional arrays from MQL4 and output their state in a pop-up window.
As far as I understand, I need to pass a two-dimensional array from MQL4 to the dll, but how to pass a two-dimensional array, if its dimensionality in the first dimension is unknown and changes in the function in MQL4.