Forum on trading, automated trading systems and testing trading strategies
Zarik, 2022.07.26 15:42
can anyone please explain me what this expression means and how the (!=) condition is being evaluated?
(m_patterns_usage&(((int)1)<<p))!=0
Checking if the p-th bit is non-zero in the binary representation of the number m_patterns_usage.
- What "&" symbol means? is this a logical operator or its a reference to the "m_patterns_usage" property?
- What does "((int)1)" means?
Please take the time to read the documentation and familiarise yourself with operators and expressions: Documentation on MQL5: Language Basics / Operations and Expressions
Bitwise Operations
Left Shift (<<)
The binary representation of x is shifted to the left by y digits, the freed right-side digits are filled with zeros.
Bitwise AND Operation (&)
The bitwise AND operation of binary-coded x and y representations. The value of the expression contains a 1 (TRUE) in all digits where both x and y contain non-zero, and it contains 0 (FALSE) in all other digits.
Operations of Relation
a != b; // True if a is not equal to b
Boolean Operations
Logical Negation NOT (!)
Operand of the logical negation (!) must be of arithmetic type. The result is TRUE (1), if the operand value is FALSE (0); and it is equal to FALSE (0), if the operand differs from FALSE (0).
Typecasting
(int)
Please take the time to read the documentation and familiarise yourself with operators and expressions: Documentation on MQL5: Language Basics / Operations and Expressions
Bitwise Operations
Left Shift (<<)
The binary representation of x is shifted to the left by y digits, the freed right-side digits are filled with zeros.
Bitwise AND Operation (&)
The bitwise AND operation of binary-coded x and y representations. The value of the expression contains a 1 (TRUE) in all digits where both x and y contain non-zero, and it contains 0 (FALSE) in all other digits.
Operations of Relation
a != b; // True if a is not equal to b
Boolean Operations
Logical Negation NOT (!)
Operand of the logical negation (!) must be of arithmetic type. The result is TRUE (1), if the operand value is FALSE (0); and it is equal to FALSE (0), if the operand differs from FALSE (0).
Typecasting
(int)
That was where my Problem laying! The Typecasting! Thank you very much!
Cheers,
Zarik
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey guys,
can anyone please explain me what this expression means and how the (!=) condition is being evaluated?
For more context, this code is part of a macro which is defined in the ExpertSignal.mqh after generating an Expert using a moving average as signal.
ExpertSignal.mqh:
my question is not about how the signal module/system is working but about the language implementation and how the syntax works in this scenario and
to be more precise:
Thank you!
Cheers,
Zarik