Retrieve new ticket number after partial close ?

 

Hi,


I need your help.


How can i retrieve the new ticket number after a partial close within the same loop or do i need to make a new loop.


Thanks


for(cnt=OrdersTotal();cnt>=0;cnt--)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{
if(Bid >= TPBuy1 && OrderStopLoss() < OrderOpenPrice() && OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==(MAGICMABO)
&& OrderLots() == lotsbuy)
{
OrderClose(OrderTicket(), NormalizeDouble(OrderLots()/2.0,digits), Ask, 5, CLR_NONE);
OrderModifyExtended(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+PipsInProfitAtTP1*Point,OrderTakeProfit(),0,White);
}
}
else if(Ask <= TPSell1 && OrderStopLoss() > OrderOpenPrice() && OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==(MAGICMABO+2)
&& OrderLots() == lotssell)
{
OrderClose(OrderTicket(), NormalizeDouble(OrderLots()/2.0,digits), Bid, 5, CLR_NONE);
OrderModifyExtended(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-PipsInProfitAtTP1*Point,OrderTakeProfit(),0,White);
}
}

 

This is the function i use:


int orderTickets[];

int start()
{
   getOrderTickets(orderTickets, 123456);

   return(0);
}




void getOrderTickets(int& orderTickets[], int magicNumber = 0){
   int c;
   
   //initialize array to 0
   ArrayResize(orderTickets, 0);

   for(c = 0; c < OrdersTotal(); c++){
      OrderSelect(c, SELECT_BY_POS);
      if(OrderSymbol() ==  Symbol() && OrderMagicNumber() == magicNumber){
         ArrayResize(orderTickets, ArraySize(orderTickets) + 1);
         orderTickets[ArraySize(orderTickets) - 1] = OrderTicket();
      }
   }
}
 
jmca:

This is the function i use:

Thank you for the idea jmca. It really helped :)

Regards,

Umer

 
Master.Aurora:

Thank you for the idea jmca. It really helped :)

Regards,

Umer

Please don't reply to 3.5 year old posts . . . jmca's last post was in June 2009, it is unlikely he will see your post.