close specific trade using orderticket()

 
hello, how do i close specific order using OrderClose(). i did get the value of the OrderTicket() but i cannot close it. i think i have problem on my code
void CloseProfit() {
               double MAXprofit=0;
               int    TicketOrder=0;
               for(int i=OrdersTotal()-1; i>=0; i--)
                  {
                  if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
                     if(OrderSymbol()==Symbol())
                        if(OrderMagicNumber()==InpMagicNumber) 
                         {
                           MAXprofit=MathMax(MAXprofit,OrderProfit()+OrderSwap()+OrderCommission());                                     
                           if(OrderProfit()>0 && OrderProfit() >=MAXprofit)
                              {
                              TicketOrder=OrderTicket();
                              Print("MAX PROFIT",MAXprofit,"OrderTicket",TicketOrder);
                              } 
                         }
                   }
                         if(TicketOrder>0)
                           {
                              if(OrderSelect(TicketOrder,SELECT_BY_POS,MODE_TRADES))
                                 if(OrderSymbol()==Symbol())
                                    if(OrderMagicNumber()==InpMagicNumber){
                                    if(OrderProfit()>=MAXprofit)
                              bool close = OrderClose(TicketOrder,OrderLots(),OrderClosePrice(),3);
                              }
                           }
             
                 }
 
Karl Robeck:
hello, how do i close specific order using OrderClose(). i did get the value of the OrderTicket() but i cannot close the specific order. i think i have problem on my code
if(OrderSelect(TicketOrder,SELECT_BY_POS,MODE_TRADES))

Should be

if(OrderSelect(TicketOrder,SELECT_BY_TICKET))
 
Keith Watford #:

Should be

tnx mate now my system is working fine