use changes the internal hidden architecture of the library, bypassing the corresponding slowing down features of MQL5/RAM. Makes sense to use if you need speed of calculations - Tester.
Free of charge increases performance by tens of per cent, at least.
Briefly, what gave such a gain on a practical task.
Refusal to work with pointers - no time is wasted on checking their validity.
Refusal to copy simple structures (A = B). For example, to access an element of an array of structures only through an index, not by copying the element into a separate structure (variable).
I had to go to a lot of trouble, but the result is great.
I think not. The function just takes an array as an argument. You can create structures with two fields. One contains the array itself, the other its name, and pass this structure to the function. But it is the same as passing the array name as a separate argument.
Which check will be executed faster to check this value: < 0 or == -1?
Technically speaking, equal evaluation always processes the whole data (32 or 64 Bit), while an unequal, smaller or greater will stop at the moment this evaluation is deterministic. But the gains are so small, CPUs nowadays dont give you back this speedup due to the way the pipelining is implemented. Not sure how this would play out if it were possible to saturate the pipeline with only one type of comparison. Maybe you would be able to measure actually an advantage over the other operator.
Practically, you can actually ignore it for integers. Its a bit different for doubles, as you usually wouldn't compare them to be equal.
A significant and measurable difference can be found, if you avoid division and try to replace them with multiplication. Also if you are able to avoid the modulo operator, which is also "just" a division.
The cost of a division is around 25 to 30 cycles, while a multiplication is around 10 cycles. (Something along these lines, varies with architecture) its round about 1:3 in cost relation.
Why? It's operationally more expensive than a direct comparison.
Please explain.
Because direct comparison of real numbers often leads to wrong results. And because of this, some people thoughtlessly apply this method wherever necessary and wherever not necessary.
And in fact, the original variant, if it differs, is very insignificant.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
But how many clock cycles, what instruction takes - dig it yourself, who is interested))))
IMHO, in practical terms, it is absolutely unimportant.
I got rid of the other.
Forum on trading, automated trading systems and testing trading strategies.
Libraries: Virtual
fxsaber, 2025.01.08 16:06
use changes the internal hidden architecture of the library, bypassing the corresponding slowing down features of MQL5/RAM. Makes sense to use if you need speed of calculations - Tester.
Free of charge increases performance by tens of per cent, at least.
Briefly, what gave such a gain on a practical task.
I pass the Close[] array to the function.
Is it possible to find out the name of this array inside this function through the code, instead of writing "Close[]" in the print?
I think not. The function just takes an array as an argument. You can create structures with two fields. One contains the array itself, the other its name, and pass this structure to the function. But it is the same as passing the array name as a separate argument.
Some variable has a value of -1.
Which check will be executed faster to check this value: < 0 or == -1?
Some variable has a value of -1.
Which check will be executed faster to check this value: < 0 or == -1?
It is better to replace a==b with (a-b)==0 , it is better.
Looks like the auto translator's glitchy.
No, everything is fine -
Forum on trading, automated trading systems and testing trading strategies
Features of the mql5 language, subtleties and tricks
Putnik, 2025.06.25 18:31
It is better to replace a==b with (a-b)==0 , it is better.
OK, thanks.
I logged in from another computer, only one error.
It is better to replace a==b with (a-b)==0 , it is better.
Because direct comparison of real numbers often leads to wrong results. And because of this, some people thoughtlessly apply this method wherever necessary and wherever not necessary.
And in fact, the original variant, if it differs, is very insignificant.
On the premise that operationally it will be cheaper. That's what my high school computer teacher said.
I can't say for sure, so I won't argue.