Features of the mql5 language, subtleties and tricks - page 84
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
Can you provide the benchmark code to demonstrate that ?
Result(Release)
And this is what happens if you run it in profiling mode
Unfortunately, the profiler can not be trusted in this case.
Result ( Release )
And this is what happens, if you run it in profiling mode
Not only is it impossible to trust the profiler in this case, but Bench1 runs 10 times faster than in Release-version!
Thank you.
Result ( Release )
Tested with Expert Advisor by strategy.
2018.04.16 14:24:28.049 Core 1 OnTester result 39725470 (µs bench1)
2018.04.16 14:26:14.629 Core 1 OnTester result 39270950 (µs bench2)
2018.04.16 14:27:13.566 Core 1 OnTester result 20467067 (µs bench3)
Another 2 times faster (but no more than 10 times faster, which is certainly due to compiler optimization).
Tested with the strategy advisor.
2018.04.16 14:24:28.049 Core 1 OnTester result 39725470 (µs bench1)
2018.04.16 14:26:14.629 Core 1 OnTester result 39270950 (µs bench2)
2018.04.16 14:27:13.566 Core 1 OnTester result 20467067 (µs bench3)
It's 2 times faster still (but no more than 10 times faster, which is definitely due to compiler optimization).
You measure the time still for the generation of ticks, not just the calculation of OnTick.
Here is only the OnTick measurement
Bench1
Bench3
By a factor of three. You can't get 10 times faster because of the multiple calls to the BenchX function. StringToDouble2 itself is indeed 10 times faster.
You're measuring time still for generating ticks, not just calculating OnTick.
...You're right.
I'm really surprised that it's 10x faster, but your function can only be used when you know the string contains a valid double value.
2018.04.16 17: 14: 16.183 170952_180416 (EURUSD, H1) StringToDouble2 (abcdef) = 5456784.0
Thank you, but this script also saves wrong.
On my monitor, the limitation on the right side is marked with a vertical line, and the screen went far beyond this line.
Let me quote the answer from the service desk:
In this case, the ChartScreenShot help should be taken literally
align_mode=ALIGN_RIGHT
[in] Mode of the narrow screenshot output. The value of the enumeration ENUM_ALIGN_MODE. ALIGN_RIGHT means alignment to the right border (output from the end). ALIGN_LEFT means left side alignment.
It means that when you set the alignment to ALIGN_RIGHT the chart will be forcibly scrolled to the right border which is similar to executing the
This behavior was laid many years ago (so historically) when there was no ChartNavigate() function yet. The align_mode=ALIGN_RIGHT guaranteed that exactly the right edge of the chart would be removed.
And when ChartNavigate() function was added, the ChartScreenShot function did not change its behavior.
Therefore, if you want to get the desired effect and not to skip the chart to the right edge, use the value ALIGN_LEFT for the parameter align_mode.
your function can only be used when you know that the string contains a valid double value.
2018.04.16 17: 14: 16.183 170952_180416 (EURUSD, H1) StringToDouble2 (abcdef) = 5456784.0
Fixed it, now it works like the original
Forum on trading, automated trading systems and trading strategies testing
Peculiarities of mql5 language, subtleties and tricks
fxsaber, 2018.04.16 13:23
If you remove the highlighted const, the execution time of the function will double. This suggests that the compiler does not always create optimal code, and it needs this kind of cues.
If we remove the selected const, the execution time of the function will be doubled. This tells us that the compiler doesn't always create optimal code, and it needs this kind of hints.
Interesting, thanks.
Please don't edit your code once you have already received the answer, I didn't get the notification you updated it.
If we remove the selected const, the execution time of the function will be doubled. This means that the compiler doesn't always create optimal code and needs this kind of hints.
Very interesting...
Any thoughts on why this happens?
What is the mechanism?
To determine the width of a screenshot taken with MQL5 that would include all the bars for a certain period, the solution below is provided.
The peculiarity turned out to be the fact that the width of the screenshot has to be corrected at different approximation of the chart.
The actual "coefficients" turned out to be different (for me specifically) for the variant with and without the scale.