Features of the mql5 language, subtleties and tricks - page 183
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
Colleagues, please help me make a macro, if at all possible.
I need to dynamically declare a two-dimensional array. And the second dimension must also be changed. This is something like this loop:
Of course, the compiler will balk at this:
I would like to see a macro like the following:
Instead of a line:
Thank you.
I use a structure array and everything works, including copying
https://www.mql5.com/ru/forum/85652/page46#comment_15990662
The only thing is that you have to write the names of the fields when you access them, but I'm fine with that
If there is an urgent need to reset static variables/arrays (including const) in EAs, a re-login is sufficient.
If you need to reset ALL static variables (including those that you yourself declared as constants), you need to change the project architecture). IMHO of course.
Can you tell me what to specify instead of ???? to make it work? Thank you
You need to tell the function the name of the class member to check the array
Can you tell me what to specify instead of ???? to make it work? Thank you
I need a way to tell the function the name of the class member by which to check the array
This option:
Such an option:
Thank you, that's an interesting option. Not quite what I'm looking for though. If I understood the code correctly, you pass a sorting function to the right hand side, but you already write the structure members in it. It means, if I need to sort by another member or another object with another member's name, I will have to create a separate function for each case. Unfortunately, it is not very optimistic. But it may be) I continue my search.
There is something similar in js, but this function with members is written inside the sort line and looks more like a simple parameter assignment, which doesn't lead to code cluttering. I am looking for a universal variant, but I'm lacking knowledge. Maybe it is done via some sort of pointers or mapping, please help.
Can you tell me what to specify instead of ???? to make it work? Thank you
You need to tell the function the name of the class member to be used to check the array.
A universal solution has been posted on the forum. You will have to search for it.
A one-size-fits-all solution was posted on the forum. You need to look it up.
Do you happen to remember which section at least? It's like looking for a needle in a haystack.)
All I remember is that it was two months ago.
Thanks, it's an interesting option. Not quite what I'm looking for though. If I understood the code correctly, you are passing a sorting function to the right hand side, but you are already prescribing the structure members in it. It means, if I need to sort by another member or another object with another member's name, I will have to create a separate function for each case. Unfortunately, it is not very optimistic. But it may be) I continue my search.
There is something similar in js, but the function with members is written inside the sort line and looks more like a simple parameter assignment, which doesn't lead to code cluttering. I'm looking for a universal variant, but I'm lacking knowledge. Perhaps this is done through some sort of pointers or mapping, please help.
Actually this is optimal. And it allows you to set more complex sorting conditions.
For example:
And there are no other solutions anyway.