can some one explain the logic

 

can some one explain the logic 

dir=((OP==OP_BUY)?1.0:-1.0);

 
Perhaps you should read the manual.
dir=((OP==OP_BUY)?1.0:-1.0);
Equivalent to:
if(OP==OP_BUY) dir= 1.0;
else           dir=-1.0;
Ternary Operator ?: - Operators - Language Basics - MQL4 Reference Works on either side of the equals
This works in the debugger:
(b ? x : y) = z;
Equivalent to:
if(b) x = z;
else  y = z;
 
thanks dear for your valuable time and fruitful comments,