Hi
Thanks codersguru
The following also checks the symbol and magicnumber (I hope)- so one doesn't get one's ea messing with each other
Code:
double GetLastProfit(string symbol1,int magicEA )
{
int total = HistoryTotal();
datetime cur_order = 0;
datetime last_order=0;
double profit=0;
for(int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()!= symbol1 || OrderMagicNumber() != magicEA) continue;
cur_order = OrderCloseTime();
if(cur_order>last_order)
{
last_order = cur_order;
profit = OrderProfit();
}
}
return (profit);
}