Download MetaTrader 5

Difference between || / &&

To add comments, please log in or register
gangsta1
1172
gangsta1 2014.07.16 11:47 

Sorry basic question I know but wondered what is the difference between using || or &&? Example for each would be:

if (OrderSymbol() == Symbol() && OrderMagicNumber() == OrderId2)
if (OrderSymbol() == Symbol() || OrderMagicNumber() == OrderId2)
honest_knave
Moderator
2419
honest_knave 2014.07.16 11:52  

|| means OR

&& means AND

 

if (OrderSymbol() == Symbol() && OrderMagicNumber() == OrderId2)

 means both the symbol and the magic number must match

  

if (OrderSymbol() == Symbol() || OrderMagicNumber() == OrderId2)

 means either the symbol or the magic number must match

gangsta1
1172
gangsta1 2014.07.16 13:44  

Thank you, perfect answer. Furthermore, what is != ?


if (OrderType() != OP_SELL || OrderSymbol() != Symbol())


honest_knave
Moderator
2419
honest_knave 2014.07.16 14:17  

!= means not equal to

Take a look here for a full list of the operations 

To add comments, please log in or register