far <= mid >= near or Order of Operator Precedence in MT4?

far <= mid >= near or Order of Operator Precedence in MT4?

Manage alerts

Loading saved threads...

Sean Champ · External communityPost link
External question — Stack Overflow Stack Exchange Author: Sean Champ Original post: https://stackoverflow.com/questions/76846987 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. When implementing a simple method of reversal detection in MQL4 for +DI/-DI indicator lines in a customized Average Directional Index indicator [ref at Investopedia] [full source code] I'd tried using the following expression for testing whether r 1 <= r 2 >= r 3 for r 1 being the rate at the oldest time-series tick of the three: if (rate_far <= rate_mid >= rate_near) { // ... } This did not work out as hoped. Candidly, it took me a minute or to two to debug this. Implemented as with the following expression, it works out: if (rate_far <= rate_mid && rate_mid >= rate_near) { // ... } Could it possibly be a quirk of the MQL4 compiler? or have I misunderstood the operator precedence here? Testing this in iPython, the original expression is interpreted as expected 20 <= 25 >= 15 # => True
Quote
Report
Sean Champ · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Sean Champ Original post: https://stackoverflow.com/a/76973654 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I think it may have something to with operator overloading in MQL4. Perhaps this may be similar to how it's been implemented in some standards of the C++ language.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Sean Champ Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/76846987 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. When implementing a simple method of reversal detection in MQL4 for +DI/-DI indicator lines in a customized Average Directional Index indicator [ref at Investopedia] [full source code] I'd tried using the following expression for testing whether r 1 <= r 2 >= r 3 for r 1 being the rate at the oldest time-series tick of the three: if (rate_far <= rate_mid >= rate_near) { // ... } This did not work out as hoped. Candidly, it took me a minute or to two to debug this. Implemented as with the following expression, it works out: if (rate_far <= rate_mid && rate_mid >= rate_near) { // ... } Could it possibly be a quirk of the MQL4 compiler? or have I misunderstood the operator precedence here? Testing this in iPython, the original expression is interpreted as expected 20 <= 25 >= 15 # => True

Cancel quote

Checking account access…