Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1163
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
If it has been entered, then there is a difference.
Reading an initialised variable is always faster than reading a function.
There is no difference. I can't find the link now - but the answer was given a long time ago.
There is no difference. I can't find the link now - but the answer was given a long time ago.
For Juan and the compiler warnings, there is no difference ))
There is no difference. When compiling, everything comes together in a single call. That's why it's better to do everything through functions.
Let's start a separate thread about it too and argue about it like about pips and points... That'll give people something to do...
You guys love to impose your opinions on everyone...
There is an MA with some shift. Let MA_shift = 5;
Why is it possible to get the right value of MA from the zero bar of the chart only if double negative shift is passed to CopyBuffer?
CopyBuffer(hMA, 0, -2*5, rates_total, MA_Buf);
MA_Buf[0] now has the correct value.
There is an MA with some shift. Let MA_shift = 5;
Why is it possible to take the correct value of MA from the zero bar of the chart, only if you pass a double negative shift into CopyBuffer?
CopyBuffer(hMA, 0, -2*5, rates_total, MA_Buf);
MA_Buf[0] now has the correct value.
Draw a picture first and specify what is "zero bar" for your indicator with the shift parameter.
Reading a variable, faster than a function.
Not really, I checked which is faster than _Symbol or Symbol()https://www.mql5.com/ru/forum/160683/page933#comment_12780905.
the access time is the same, code optimization in MQL is very cool, so use whatever is convenient.
according to my tests the access time may be different depending on where the variable is described and with what modifiers, but there is a 2-5% speed, which in principle can be written off to the implementation in a particular build, it depends on the build number
Could you please advise how to easily and quickly get the result of the last trade with the current symbol? Because the documentation is very complex. To get the result, you need to find the ticket of the required trade first, to find the ticket you need to find the trade in the history by its index, the index should be sought in the history, not to mention that we should filter filter by the symbol.
To avoid going to the trading history every time - just catch the deal inOnTradeTransaction with the type
TRADE_TRANSACTION_DEAL_ADD - adding transaction to the history
m_symbol.Name() - current symbol, InpMagic - unique identifier of the Expert Advisor
not a fact, I checked which is faster than _Symbol or Symbol()https://www.mql5.com/ru/forum/160683/page933#comment_12780905
I.e. access time is one and the same, code optimization in MQL is very cool, so whatever is convenient, use it.
according to my tests the access time may be different depending on where the variable is described and with what modifiers, but there 2-5% speed, which in principle can be written off to the implementation in a particular build, it depends on the build number
I agree that the optimizer works well, but relying always on the compiler's optimizer is wrong.
Oddly enough, they are in mql as undocumented.You need to think ahead about how the code is executed at the memory, initialization and value return level.
That is, calculate the number of executed actions per operation and if there are fewer actions, the code is faster. And take it as a practice to write an optimal code at once.
In short codes perhaps there is no difference, but when there is a project with hundreds of files, that's when delays will appear,
and there will only be a profiler and rewrite the code. Everyone chooses his own rake )).
Also google for keywords