Order ticket#

 
In my EA I have multiple lots. After a price is reached I scale out by taking one lot off.

The ticket # is i closed and goes into Account History trades and a new ticket# is created which shows up in trades screen.
If I attempt to modify the stop loss on the remaining lots, I get an unknown ticket number. The log file shows that it tried to modify using the ticket number of the lot (original ticket#) that was closed.

When I am doing the following to get the ticket# of the active trades, I get the old ticket # that was closed.


int total = OrdersTotal();
int ticket;

for (int n = 0; n < total; n++)
{
OrderSelect(n, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol()== Symbol())
{
ticket = OrderTicket();
break;
}

// ticket has the ticket#



How can I get the new ticket # of the remaining lots?
 

You can analyze comment "split from #XXXXXX"

MagicNumber still the same