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

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
Application
Result
Handy sorting an array of structures
Yellow highlighted the missing things, and it seems to me that it's better in order of arguments, first Start, and then Count.
By the way, it is probably more reasonable to sort arrays of structures by indexes (I mean rearrange indexes, not structures themselves), but it depends on the size of the structure, of course.
I highlighted in yellow what was missing.
Thanks, I missed it.
I think it's better to start with Start and then Count in order of arguments.
The signal is borrowed from MT4-ArraySort.
By the way, it would probably be more reasonable to sort arrays of structures by indexes (I mean rearrange indexes, not structures themselves).
This was the first thing that came to mind, but I gave it up. Because it requires using ArrayCopy of the initial array and the array of indexes. And this is additional memory. And the machine cannot afford such sorting of an array, for example, of millions of MqlTick-elements.
We could have included two sorting variants, but I haven't done it in the source code. In the demonstration, perhaps, the most valuable thing is usability and method of implementation. After studying it, it is already clear how to add to your needs and make an analogue for other functions of arrays with structures (ArrayMaximum, etc.).
Handy sorting an array of structures
Application
Result
How to convert this code to a simple class without using #define ?
How to convert this code to a simple class without using #define ?
You can't. ArraySortStruct is supposed to be used as a function without getting into how it is organized.
Just throw in some enludnik its source code and forget about it. After that a really handy for any beginner (and not only) "function" is always at hand.
A random number from 0 to max with equal probability:
The multi-buffer is great for speeding up the editor and is safe.
It does not write anything to disk and only keeps data in memory.
A random number from 0 to max with equal probability:
Your function is 100% equivalent:
because, firstly.
simplifies to
therefore, secondly
is always performed once.
Complexity is a detailed statement of simplicity. ))
Your function is 100% equivalent:
because, firstly.
simplifies to
therefore, secondly
is always performed once.
Complexity is a detailed statement of simplicity. ))
You are very considerate, thank you. I made a mistake, didn't put brackets, so I would use "unfair" function.
SZZ: made corrections to the original post.