Put it simply, how do you think MQL4 would interpret the following incorrect formula:
MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2]&&Close[1]>Open[2])
which was meant to be written as:
MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&Close[1]>Open[2]
MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2]&&Close[1]>Open[2]) MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&Close[1]>Open[2]
I don't see any difference between the 2 lines of code except the missing final ")" in the 2nd line
Please use the SRC button when posting code and it may help to present it in a more reader friendly style
eg.
if(Close[1]>Open[1] && Close[2]<Open[2] && MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-close[2] && Close[1]>Open[2])) BullishEngulfing = true; else if (Close[1]<Open[1] && Close[2]>Open[2] && MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2] && Close[1]<Open[2])) BearishEngulfing = true;
.
I don't see any difference between the 2 lines of code except the missing final ")" in the 2nd line
Please use the SRC button when posting code and it may help to present it in a more reader friendly style
eg.
.
Thanks for the response. It is not a missing bracket but the bracket in the wrong place. As a result it gives a warning on compiling and strangely a better result on back testing. Thanks for letting me know about the SRC button. Will use it next time.
Cheers.
if(Close[1]>Open[1]&& Close[2]<Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-close[2]&&Close[1]>Open[2]))BullishEngulfing = true;
- Are you resetting the boolean variables to false.
make your conditions readable. bool isUp = Close[1] > Open[1]; bool wasDown = Close[2] < Open[2]; bool isLarger = MathAbs(Open[1]-Close[1]) > MathAbs(Open[2]-close[2]); bool isMoving = Close[1]>Open[2]); BullishEngulfing = isUp && wasDown && isLarger && isMoving; BearishEngulfing = !isUp && !wasDown && isLarger && !isMoving;
It is like writing
(a) MathAbs(A-B)> MathAbs(C-D && E>F)
instead of
(b) MathAbs(A-B) >MathAbs(C-D) && (E>F)
How would MQL4 interpret (a)
Thanks for the response. It is not a missing bracket but the bracket in the wrong place. As a result it gives a warning on compiling and strangely a better result on back testing. Thanks for letting me know about the SRC button. Will use it next time.
Cheers.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
if(Close[1]>Open[1]&& Close[2]<Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-close[2]&&Close[1]>Open[2]))BullishEngulfing = true;
else if (Close[1]<Open[1]&& Close[2]>Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2]&&Close[1]<Open[2]))BearishEngulfing = true;
I wrote the above two lines by mistake when what I really meant to write was the following
if(Close[1]>Open[1]&& Close[2]<Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&Close[1]>Open[2])BullishEngulfing = true;
else if (Close[1]<Open[1]&& Close[2]>Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&Close[1]<Open[2])BearishEngulfing = true;
Strangely, the first two incorrect lines give me a better result than the correct ones on back testing!
Can someone tell me how MQL4 would interpret my incorrect lines please.
Put it simply, how do you think MQL4 would interpret the following incorrect formula:
MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2]&&Close[1]>Open[2])
which was meant to be written as:
MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&Close[1]>Open[2]