how can i Get Last deal profit?

 

Hi

How can i  get profit of last deal?


            
 

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

 
Osama Shaban:

Salam Mohsen ...

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

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

 I found this helpful.

Thanks.

Reason: