Download MetaTrader 5
To add comments, please log in or register
Unable to find the answer to your question? Use the search!
itriad
162
itriad 2014.01.06 11:30 
sometime last closed trade wasn\'t found??????

bool GetLastCloseTradeProfit(double &lastClosedPrice, double &lastClosedProfit)
{
   datetime lastClosedTime = 0;
   lastClosedProfit=0.0;

   //-- Loop history orders
   for(int pos=OrdersHistoryTotal() - 1;pos >= 0; pos--)
   {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)==false) continue;
      
      if(OrderMagicNumber()==Magic && OrderSymbol()==Symbol() &&
         (OrderType()==OP_BUY || OrderType()==OP_SELL) &&
         OrderCloseTime() > lastClosedTime
         )
      {
         lastClosedTime = OrderCloseTime();
         lastClosedPrice = OrderClosePrice();
         lastClosedProfit = OrderProfit();
      }
   }
   bool winner=lastClosedProfit>0.0;

   //-- Check results
   if(lastClosedTime==0)
   {
      Print("Error last closed trade wasn\'t found, an unkonwn error occured.");
      return(false);
   }
   else
      return(winner);
}
Tjipke de Vries
6276
Tjipke de Vries 2014.01.06 11:51  
riskoff:
sometime last closed trade wasn\'t found??????


Check terminal ==>> Account History ==>> Profit

right click on profit

choose All History to display

then try again, might be you had selected last month

itriad
162
itriad 2014.01.06 12:07  
thank you i will try
/
To add comments, please log in or register