Download MetaTrader 5

Difference between || / &&

To add comments, please log in or register
gangsta1
1197
gangsta1  

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
2328
honest_knave  

|| 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
1197
gangsta1  

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


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


honest_knave
Moderator
2328
honest_knave  

!= means not equal to

Take a look here for a full list of the operations 

To add comments, please log in or register