Download MetaTrader 5

how can i Get Last deal profit?

To add comments, please log in or register
mohsen bahrami
284
mohsen bahrami  

Hi

How can i  get profit of last deal?

Osama Shaban
1619
Osama Shaban  

Salam Mohsen ...

This is my own function, I used it in one of my EAs successfully ...

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()==MagicNumber && OrderProfit()!=0){
         LastOrderType = OrderType(); 
         LastOrderLots = OrderLots(); 
         LastOrderProfit = OrderProfit(); 
         LastOrderStopLoss = OrderStopLoss();
         LastOrderTakeProfit = OrderTakeProfit();
      }
   }
}

 It gives you the following ...

         LastOrderType, LastOrderLots, LastOrderProfit, LastOrderStopLoss and LastOrderTakeProfit.

You can cancel any of those who you don't need but remember, you have to declare these variables globally (before start function). 

To add comments, please log in or register