please help! my EA does not close open order on condition. is my code wrong?

 
this is my code:I have tried it several times with different conditions.thanks for(cnt=0;cnt 0) { if(Bid-OrderOpenPrice()>MarketInfo(Symbol(),MODE_POINT)*TrailingStop) { if(OrderStopLoss() isar(NULL,15,0.02,0.2,0)) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } } // check for trailing stop if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) { if((OrderStopLoss()>(Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } }
 

Translated

for(cnt=0;cnt 0) 
{ if(Bid-OrderOpenPrice()>MarketInfo(Symbol(),MODE_POINT)*TrailingStop) 
{ if(OrderStopLoss() isar(NULL,15,0.02,0.2,0)) 
   { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position 
return(0); // exit 
} 
} 

// check for trailing stop 

if(TrailingStop>0) 

{ if((OrderOpenPrice()-Ask)>(MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) 
  { if((OrderStopLoss()>(Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop)) || (OrderStopLoss()==0)) 
   { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MarketInfo(Symbol(),MODE_POINT)*TrailingStop,OrderTakeProfit(),0,Red); 

return(0); 
   } 
  } 
} 
} 
} 
}

Does this compile?

Please post code with the SRC button :)

Code as seen cannot work as no OrderSelect() has been done - you have to track the ticket number or loop through the pool of orders to grab an order then evaluate then Close.

Good luck

-BB-

Reason: