find pending position deleted time in history by its position ticket number

 

Hi, I going to complete this function to draw closed positions user added to chart. two type of positions we have here : those that opened and pending orders that deleted by user. I have position ticket of all positions in array Closed_order_list[].ticket.

problem is for pending orders that never opened. how can I find them in history by its ticket number ? i need history to find out order closed time

this functions Do its job pefectlly on opened positions. 


void ReDrawClosedPositions()//(ulong positionTicket, datetime closedTime)
  {
   PendingOrderInfo info;
   CPositionInfo m_position;

   int iLast = 0;
   ulong drawed[];



   for(int i=0;i<Closed_order_list.Size() ;i++)
     {

      if(!m_position.SelectByTicket(Closed_order_list[i].ticket) && (array_contains(drawed,Closed_order_list[i].ticket) < 0)) //draw
        {
         if(HistorySelectByPosition(Closed_order_list[i].ticket))
           {
            CDealInfo tempdeal;

		//this for just fill symbol name for Closed_order_list[i]
            for(int m=0;m< HistoryDealsTotal();m++)
              {
               ulong dealticket = HistoryOrderGetTicket(m);
               //Print("dealticket = "  + dealticket);
               int count = HistoryDealsTotal();
               //Print("DealsTotal =" + count);
               if(tempdeal.SelectByIndex(0))
                 {
                  if(tempdeal.Order() == Closed_order_list[i].ticket)
                    {
                     Closed_order_list[i].symbol = tempdeal.Symbol();
                    }

                 }
              }


           
            if(Closed_order_list[i].symbol == Symbol())
              {
               DrawPosition(i, pos_close_time);

               iLast = ArraySize(drawed);
               ArrayResize(drawed, ArraySize(drawed) + 1);
               drawed[iLast] = Closed_order_list[i].ticket;
              }


           }

        }


     }

  }

screen shot of What I draw for positions listed in Closed_order_list :

screenShot