Information to all
Hi guys,
I deal with now time optimalization mql code. I have found that preprocesor mql language test all boolean conditions even though the result is clear already after some condition.
Example: When 5 conditions type boolean and your code is:
if ( cond1 & cond2 & cond3 & cond4 & cond5 ) ...
if cond1 is false -> is clearly that result all conditions is false so. But MQL preprocesor testing all conditions. If "cond.." is example function with return boolean type, can it calcul operation inside this function more time - unnecessarily!
Demonstrativ code:
My question - Does have mql preprocesor some direktive for it? I would like write code as if ( cond1 & cond2 & cond3 & cond4 & cond5 ) ... and at the same time I need time optimalization code.
Thank you.
What do you mean by the "preprocessor test all boolean conditions" ? Anyway, during runtime the processing follows the C++ standards for 600+ code (with strict directive).
If I have conditions: 1.) false 2.)true 3.) true 4.) true and 5.) true
and code if ( cond1 && cond2 && cond3 && cond4 && cond5 ) {...}
process running and testing all conditions although result is clearly after test the first condition.
if ( cond1 & cond2 & cond3 & cond4 & cond5 ) ...
if cond1 is false -> is clearly that result all conditions is false so. But MQL preprocesor testing all conditions. If "cond.." is example function with return boolean type, can it calcul operation inside this function more time - unnecessarily!
Is necessary. It has to compute all five because you are computing a bit mask. 1 & 2 & 4 == 0 Bitwise Operations - MQL4 Documentation
Use boolean operators cond1 && cond2 && cond3... Boolean Operations - MQL4 Documentation
Hi WHRoeder,
I have no doubt that you know more about mql than I do... but my time test code does not endorse what you write:
"the calculation of the expression is terminated when the result of the expression can be precisely estimated."
For my basic time test code on top page - quickly version time test is 0ms, slowly version about 10ms. I repeted test many times. It is fact.
Hi endy5!
You can`t compare your 2 versions.
If you are computing a BIT MASK, you can't split the Operation into two ore more lines. If you do so, you'll get a different result.
I think you will do a LOGICAL Operation (your variables are bool and initalized with false). Therfore you have to use && as Boolean Operator.
Hi.
I am sorry. Very stupid my inattention! You have the right!
Perhaps it would be better to delete the whole thread, because it is just wrong. Does not have any information for others users.
I am sorry.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Information to all
Hi guys,
I deal with now time optimalization mql code. I have found that preprocesor mql language test all boolean conditions even though the result is clear already after some condition.
Example: When 5 conditions type boolean and your code is:
if ( cond1 & cond2 & cond3 & cond4 & cond5 ) ...
if cond1 is false -> is clearly that result all conditions is false so. But MQL preprocesor testing all conditions. If "cond.." is example function with return boolean type, can it calcul operation inside this function more time - unnecessarily!
Demonstrativ code:
My question - Does have mql preprocesor some direktive for it? I would like write code as if ( cond1 & cond2 & cond3 & cond4 & cond5 ) ... and at the same time I need time optimalization code.
Thank you.