Download MetaTrader 5

how can i Get Last deal profit?

To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
mohsen bahrami
mohsen bahrami 2016.08.26 14:52 


How can i  get profit of last deal?

Osama Shaban
Osama Shaban 2016.08.26 18:46  

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