Features of the mql5 language, subtleties and tricks - page 296

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
By the way, if someone is interested in programming dates, we could write a mini-library for working with dates before 1970. There was some life there)).
For programming tasks not related to market/forex.
Who knows how to make this work ?
to get a Sort template ( array_pointers, compare_function )
While using a sort function that accepts a function pointer to compare function is the standard approach for sorting array structures or object pointers, there is a much simpler technique "Operator overloading" that works with a plain sort function without the need for writing a separate compare function.
Sorting array of structures by operator overloading:
Also for sorting array of structures, we add an overloaded operator:
This allows to simply sort like: Sort(structArray);
We also add an overloaded operator to sort arrays of structures:
This allows simple sorting like: Sort(structArray);
It is often necessary to sort such an array by different fields.
There seem to be many implementations of such sorting in this thread. When the user has almost nothing to write.
It is often necessary to sort such an array by different fields.
I think there were many implementations of such sorting in this thread. When the user doesn't need to write almost anything.
user-user:
INC_SORT_BY(array,field) - sort an array of structures by a given field;
Shorter is hardly possible anymore :-)
Forum on trading, automated trading systems and testing trading strategies
Features of mql5 language, subtleties and techniques of work
Maxim Kuznetsov, 2025.03.21 09:30 AM
Forum on trading, automated trading systems and testing trading strategies
Features of mql5 language, subtleties and techniques of work
Maxim Kuznetsov, 2025.03.21 09:30
Forum on trading, automated trading systems and testing trading strategies
Features of mql5 language, subtleties and techniques of work
Maxim Kuznetsov, 2025.03.21 09:30 AM
it's all handwritten :-)
my computer died at the weekend, now I'm doing it all over again and I haven't managed to get the sources from the backups yet
in the given code except that names do not like...a little differently it is necessary to name.
PS/ there are still problems with Print() and templates/arrays in MQL. The built-in Print does not work like all the others
PPS/ ArrayPrint is inconvenient because it prints the whole array (they can be of epic size). You still have to redefine it, reducing the output