Close single order

To add comments, please log in or register
GrumpyDuckMan
882
GrumpyDuckMan  

Hello everyone,

I am trying to simplify closing order.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePosition()
  {
   index= OrderType();
   Trade=(OrderSelect(TicketNumber,SELECT_BY_TICKET)==true);
   bool Order_Closing = OrderClose(TicketNumber,lot,Closing[index],Slippage,clrNONE);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

some ideas please

William Roeder
20208
William Roeder  
  1. index= OrderType();
    You can not use any Trade Functions until you select an order.

  2. Trade=(OrderSelect(TicketNumber,SELECT_BY_TICKET)==true);

  3. bool Order_Closing = OrderClose(TicketNumber,lot,Closing[index],Slippage,clrNONE);
    • Check your return codes.
    • You've selected the ticket, you don't need other variables, just use OrderClose(OrderTicket(), OrderLots(), OrderClosePrice().

  4. You are selecting by ticket, (not a OrderSelect loop through open orders.) Where do you check if the order has already closed?

  5. GrumpyDuckMan: some ideas please
    You haven't stated a problem.
To add comments, please log in or register