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

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
With the help from codes by fxsaber here and here and some codes from this webpage source code, I was able to devise a very fast function to get year, month and day of year.
I updated the previous test done by Nokali before.
Results:
Edit:
GetMonthFast() uses branchless code, no if statements, and I think memoisation is not required because it takes only 2 nanosec to execute.
May be the comparisons with TimeToStruct() is not fair enough (it has to calculate all the other members of the struct), but it was included here to verify checksums.Wow! Bravo!
Thanks, Amrali
Conclusion:
(1) The decoding of datetime variables into the calendar dates (year, month and day) is fast enough. The TimeToStruct() function is doing a very good job at extraction.
(2) The encoding routines for converting calendar dates into datetime variables are really slow, encoding benchmarks here had showed speed-ups of100x times or more.
I think the StructToTime () and StringToTime () need some consideration from the developers , because these functions are frequently used in experts / indicators on the platform to encode datetime .
Yes, there is an obvious performance-affecting semantic bug in StructToTime( ) function
As a temp solution to add an optimized StructToTime() to the existing experts and indicators that heavily use this function, this can be done with minimal code change:
StructToTime.mqh
your existing code:
some codes from this webpage source code
Thanks, interesting source code.
I was able to devise a very fast function to get year, month and day of year.
Great to put the best solutions together. A little acceleration.
As a temporary solution to add the optimised StructToTime() function to existing EAs and indicators that actively use this function, this can be done with minimal code changes:
Why didn't CreateDateTime6?
Probably it makes sense to make a temporary solution for TimeToStruct as well.
Why didn't they use CreateDateTime6?
We can summarise
A set of fast structure-less functions to get date and time parameters up to 2100 by a single input parameter datetime:
GetDayOfYeah?
And GetDayOfYeah?
Forum on trading, automated trading systems and testing trading strategies
Peculiarities of mql5 language, subtleties and techniques of work
fxsaber, 2024.04.20 09:42
We should either create a separate topic for these codes,
or move them to the blog, otherwise they get lost.