English

## MQL4 Formula Interpretation

 19 Tony227 2015.12.08 21:17   Hi there,  if(Close[1]>Open[1]&& Close[2]MathAbs(Open[2]-close[2]&&Close[1]>Open[2]))BullishEngulfing = true;  else if (Close[1]Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2]&&Close[1]Open[1]&& Close[2]MathAbs(Open[2]-Close[2])&&Close[1]>Open[2])BullishEngulfing = true; else if (Close[1]Open[2]&& MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2])&&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]
 Moderator3419 GumRai 2015.12.08 21:44 #   Tony227: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]MathAbs(Open[2]-close[2] && Close[1]>Open[2]))     BullishEngulfing = true; else if (Close[1]Open[2] && MathAbs(Open[1]-Close[1])>MathAbs(Open[2]-Close[2] && Close[1]
 19 Tony227 2015.12.08 21:53 #   GumRai:   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.
13006
WHRoeder 2015.12.08 22:03 #

Tony227:

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;

1. Are you resetting the boolean variables to false.
2.  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; ```
 19 Tony227 2015.12.08 22:31 #    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)
19
Tony227 2015.12.08 22:32 #

WHRoeder:
1. Are you resetting the boolean variables to false.