Download MetaTrader 5

how can i Get Last deal profit?

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


How can i  get profit of last deal?

Osama Shaban
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(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