int LastClosedTicket()
{
datetime last_closed = 0;
int last_ticket = -1;
for (int i=0; i<OrdersHistoryTotal(); i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue;
if (OrderType()<=1) {
if (OrderCloseTime() > last_closed) {
last_closed = OrderCloseTime();
last_ticket = OrderTicket();
}
}
}
return(last_ticket);
}
double LastClosedProfit()
{
int last_ticket = LastClosedTicket();
if (last_ticket > 0) {
if (OrderSelect(last_ticket,SELECT_BY_TICKET,MODE_HISTORY))
return(OrderProfit());
}
return(0.0);
}