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
A forum on trading, automated trading systems and the testing of trading strategies
Features of the MQL5 language, nuances and techniques
fxsaber, 19 June 2022 16:17
For the specific case where a numeric field is used for sorting (the most common scenario), I’ve written a version that is several orders of magnitude faster than the previous one. However, it uses twice as much memory. This is relevant for large arrays.
Result.
Please have a look in the English section:
The English section at https://www.mql5.com/en/code/53970 also mentions 2024.
It would be great to do something with iBarShift(...) – it’s a frequently used function.
Are there any examples of how it could be made faster? And whilst we’re at it, iTime, iHigh and so on.
We need to suggest some options to the developers.
Implemented in build 6002, available on MetaQuotes-Demo
We even managed to beat it in the first instance.
Thanks for the example!
Forum on trading, automated trading systems and testing trading strategies
Features of the mql5 language, subtleties and tricks
amrali, 2026.07.03 01:23
Benchmarks:
Compiler Version: 6013:
Thank you.
If you are unable to compile the code because there are errors in an unused function, the problem can be quickly resolved by adding the following line.
I revisited the previous benchmark results and noticed something that may explain the large performance gap.
I suspect that the current implementation in compiler version 6013 uses signed arithmetic, whereas the original Neri-Schneider reference implementation is based on unsigned arithmetic.
To make the benchmark fairer, I modified TimeToStructFast() to perform the same input validation (here) as the built-in TimeToStruct() :
This adds the same range check before the conversion, making the comparison more direct.
With the additional validation, the updated results (in the attched script) are:
Even after adding the extra range check, TimeToStructFast() remains approximately 35% faster than the built-in TimeToStruct() while producing identical checksums.
TimeToStruct_Signed() has a comparable performance to the built-in TimeToStruct().
If my assumption about the signed vs. unsigned arithmetic is correct, there may still be room for further optimization in the built-in implementation.
Forum on trading, automated trading systems and testing trading strategies
Libraries: High-Performance Time Functions (TimeUtils)
amrali, 2026.07.18 17:47
Update 18 July 2026 - version 2.50
Updates are only available in the English version at https://www.mql5.com/en/code/53970
It seems the issue has been resolved (as a test reboot to version 6002)
enum eHours { _0, _4, _6, _8, _12, _16, _24, _32, _48, _64, _96, _128 }; input eHours TrendHours = _8; int eHours2Hours(eHours e) { switch (e) { case _0: return 0; case _4: return 4; case _6: return 6; case _8: return 8; case _12: return 12; case _16: return 16; case _24: return 24; case _32: return 32; case _48: return 48; case _64: return 64; case _96: return 96; case _128: return 128; default: return -1; } }