Download MetaTrader 5

detect the last order status

To add comments, please log in or register
Have you found an interesting application? Publish it in Code Base - millions of traders will appreciate that!
eagleeyes0618
12
eagleeyes0618 2016.05.03 08:17 

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. :)

Osama Shaban
1451
Osama Shaban 2016.05.03 11:18  

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(); 
      }
   }
}		
To add comments, please log in or register