Download MetaTrader 5
To add comments, please log in or register
Do you have questions on how to turn your idea into reality? Ask them on the Forum!
sdoppke
70
sdoppke 2015.08.31 19:00 

Hi everyone, I am using this function to return today's profit for a specific pair and specific magic number for today only.  but it seems to be totaling all magic numbers


Does anyone see where I might be going wrong?


double CCIDailyProfit()
{
  double CCIprofit = 0;
 
  int cnt4 = OrdersHistoryTotal();
  for (int i4=0; i4 < cnt4; i4++)   
  {
    if (OrderSelect(i4, SELECT_BY_POS, MODE_HISTORY) 
    &&  OrderSymbol() == Symbol() 
    &&  OrderMagicNumber() == CCI_Magic
    &&  TimeDayOfYear(OrderCloseTime()) == DayOfYear() 
    &&  TimeYear(OrderCloseTime()) == Year());
    CCIprofit += OrderProfit()+OrderSwap();
  }
 
  return (CCIprofit);
}
Keith Watford
Moderator
7986
Keith Watford 2015.08.31 22:36  
    &&  TimeYear(OrderCloseTime()) == Year());
Remove the semicolon
sdoppke
70
sdoppke 2015.09.01 21:32  
So helpful, thank you!!
/
To add comments, please log in or register