detect the last order status

 

Hi All, 

Could anybody give me an idea about

how to detect the last running transaction order status

whether it is still running or has been closed(because it reach the TP or SL) ?

 

where will i start from to reach this result ? 

Many thanks in advance. 

 

my apologize for my bad english. :)

 

I coded this function several years ago ... It worked perfect for me to detect last closed trade (History) in case the profit was in loss ...

You can change it according to your needs. You just need to do minor changes ... 

void LastClosedTrade(){ 
   int cnt, total; 
   total = OrdersHistoryTotal(); 
   for(cnt=0;cnt<total; cnt++){ 
      if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==true)
   
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNo && OrderProfit()!=0){
         LastOrderType = OrderType(); 
         LastOrderLots = OrderLots(); 
         LastOrderProfit = OrderProfit(); 
      }
   }
}		
Reason: