last_order_profit(int magic)

Back to topics list To post a new topic, please log in or register
avatar
15
el3reef 2016.08.23 15:54
 

double last_order_profit(int magic){
 
   for(int i=OrdersHistoryTotal();i >= 0;i--)
     {
     
         OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); 
         if (OrderMagicNumber() == magic){
             
           break;
         }
 
     }
 
   return OrderProfit();
}

 

avatar
Moderator
3405
GumRai 2016.08.23 16:20 #
 
As in your other topic, is there a point here?
avatar
12985
WHRoeder 2016.08.23 18:36 #
 
  for(int i=OrdersHistoryTotal();i >= 0;i--){
     OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); 
     if (OrderMagicNumber() == magic) break;
You are assuming that history is orders, it isn't. Go through all orders and remember the last closed one and it's profit (=OrderProfit()+OrderSwap()+OrderCommission())
Back to topics list  

To add comments, please log in or register