Features of the mql5 language, subtleties and tricks - page 255
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
I checked days_from_civil() and epoch_days_fast() from the links you sent.
They are not the fastest (maybe it is the MQL5 compiler).
There's interest in the explanations there.
x64:
this option does not work. The checksum is not correct. It's limited to one month. You must have forgotten.
Different processors. I have a 13th generation Intel
this option doesn't work. The checksum is not correct.
Forum on trading, automated trading systems and testing trading strategies
Peculiarities of mql5 language, subtleties and techniques of work
fxsaber, 2024.04.16 12:46 AM
To simplify, I decided to look for the month in year zero - 1970.
There solved a different problem - search for the day of the month. I have not tried the GetMonth task.
It was solving a different problem - finding the day of the month. I haven't tried the GetMonth task.
Updated Benchmarks
Fastest functions to construct datetime values from date components (year, month and day).
Benchmark:
Results:
X64:AVX2:
Impressive speedup! more than 3000x times faster than the native way (StructToTime).
Also faster than all the variations posted before.
MQL compiler is doing some magic!
previous benchmark here
Impressive acceleration! More than 3000 times faster than the native method (StructToTime).
Also faster than all variants posted earlier.
The MQL compiler works magic!
previous benchmark here
If you disable compiler optimisation.
The results of the optimiser are too fantastic. This is most likely the reason why Nikolay does rand-sampling.
The checksum with iBarShift will not match , because iBarShift works with real bars. The checksum will match only on MN1 and W1 timeframes, because there are no holes in the history of such bars.
I have no match on GBPUSD, I changed only the first print.
I don't have a match on GBPUSD, only changed the first print.
Well, if the checksum is the same with the calculation through the structure, then MN1 has history holes.
Maybe the history hasn't loaded yet, or the validation range is larger than the historical data
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:
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.