Last trade closed by expert.

 
How can I select this particular trade?
 
OrderSelect(ticket,SELECT_BY_TICKET); // ticket is from last TradeClose executed;
 
What if you don't have the last ticket? (e.g. closed via take profit).
 
then you have to improvise, like:

loop thru history and find ticket with latest closing date,
save ticket number upfront then if trades=0 check that ticket.
save multiple tickets in array then if trades less then array tickets check which trades have closed
by comparing still open tickets against your array.
It all depends on a particular situation but there is a million of ways.

Maybe i can make a nice living writing little cute routines liek that and charging $25 a piece. :)
 
So the trade order by index is not the closing order?
 
it doesn't have to be. There is no guarantee that it will.
 
That would just be too simple right?
Reason: