Only 1 position open and only this position close.. Help me for Ticket numbers please.. - page 2

 
Emre Bahtlı:

Thank you for your interest. I will continue to wait for the lineup I want. I will be very glad if you can come back when you switch to PC. I will continue to research and try. I think we will be able to do what I want better with void. because I have to open other processes and also close them with signals. 'll see.

try this

//+------------------------------------------------------------------+
//| Check for close order conditions                                 |
//+------------------------------------------------------------------+
void Close()
  {

//---
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MagicNumber || OrderSymbol()!=Symbol()) continue;
      //--- check order type 
      if(OrderType()==OP_BUY)
        {
         if("your closing buy condition here")
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
      if(OrderType()==OP_SELL)
        {
         if("your closing Sell condition here")
           {
            if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White))
               Print("OrderClose error ",GetLastError());
           }
         break;
        }
     }
//---
  }
Reason: