Trying to close an order

 

Hello i got the next code: 

     OrderSelect(0,SELECT_BY_POS,MODE_TRADES);     
      
      int Ticket = OrderTicket();
      
 
      Comment("Beneficios ", Beneficios);
      OrderClose(Ticket,NContratos,Bid,10,clrYellow);

for trying to close an existing order, the code belongs to a function which is called just in case OrdersTotal > 0 and i have a filter which just allow 1 order at the same time.

Thats closing perfectly on strategy tester but once i test on trading demo account, having activate live trading:   Tool > Options > Expert advisor tab > Allows automated trading. Not closing :S any ideas?

 
  1. Check your return codes and find out why. Check your return codes (OrderSelect and OrderClose) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  2. No filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
Reason: