Features of the mql5 language, subtleties and tricks - page 258
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
That's what this thread is for. Why do you need another one?
In this one - search and discussion, and the new one - for recorded finds. It would be even with a table of contents in 1 post.
That's what this thread is for. Why do you need another one?
I kind of do, but, um. no.
A faster TimeToStruct() function for decoding of datetime variables, to get all the components of date and time.
Some parts of the code can be re-used to extract the components of interest, separately.
Benchmark:
Results:
A faster TimeToStruct() function to decode time-of-day variables to get all date and time components.
Some parts of the code can be reused to retrieve components of interest individually.
Benchmark:
Results:
Very cool! Especially the fact that static arrays are not used. We can take this function as a basis.
Thanks @amrali for the research and work done.
Only it is important to understand that after the compiler optimisation, the function code will be simplified and those values of the MqlDateTime structure that do not take part in the checksum calculation will not be calculated.
Therefore, the objective result will still be with this calculation:
uint mm =dt.year+ dt.mon+ dt.day+ dt.hour+ dt.min+ dt.sec+ dt.day_of_week+ dt.day_of_year; sum+=mm;
result:
Only it is important to understand that after the compiler optimisation, the function code will be simplified and those values of the MqlDateTime structure that do not take part in the checksum calculation will not be calculated.
Therefore, the objective result will still be with this calculation:
result:
Forum on trading, automated trading systems and testing trading strategies
Peculiarities of mql5 language, subtleties and techniques of work
fxsaber, 2024.04.16 17:56
Unfortunately, the source code of StructToTime is not analysed by the compiler, but is attached as an imformed function. Therefore, StructToTime counts all fields of the structure at each call.
TheMQL5 compiler is able not to count unused fields, but this requires the source code to be analysed.
MQ has repeatedly said that they will include the source code of standard functions at compilation. Unfortunately, this did not happen with StructToTime.
Good to know that!
Thanks.
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:
For completeness, does anyone want to add GetWeekOfYear?
For completeness, does anyone want to add GetWeekOfYear?
A faster TimeToStruct() function to decode time-of-day variables to get all date and time components.
That's a strange code. Have you compared performance with this solution?
Forum on trading, automated trading systems and testing trading strategies
Features of mql5 language, subtleties and techniques of work
fxsaber, 2024.04.16 14:08
I wrote a custom TimeToSruct, it is not faster than the original. Overminded somewhere.