Download MetaTrader 5
To add comments, please log in or register
One billion tasks have already been executed with MQL5 Cloud Network. Test trading robots even faster!
Sherif Hasan
7223
Sherif Hasan 2015.09.06 18:53 

Is there any standard function to get total closed orders for current day?

eg:

must count only closed orders count day by day!

if there is no standard function available please give me a suggetion to get daily orders count?

Subgenius
572
Subgenius 2015.09.07 00:13  
sheriffonline:

Is there any standard function to get total closed orders for current day?

eg:

must count only closed orders count day by day!

if there is no standard function available please give me a suggetion to get daily orders count?

try this..ty
int TodaysOrders()
   {
   for(int TotalOrdersCNT=OrdersTotal()-1; TotalOrdersCNT>=0; TotalOrdersCNT--)
      {
      if(OrderSelect(TotalOrdersCNT,SELECT_BY_POS,MODE_TRADES))
         {
         if(TimeDayOfYear(OrderOpenTime())==TimeDayOfYear(TimeCurrent()))
            {
            TotalOrders+=1;
            }         
         }
      }
   for(TotalOrdersCNT=OrdersHistoryTotal()-1; TotalOrdersCNT>=0; TotalOrdersCNT--)
      {
      if(OrderSelect(TotalOrdersCNT,SELECT_BY_POS,MODE_HISTORY))
         {
         if(TimeDayOfYear(OrderOpenTime())==TimeDayOfYear(TimeCurrent()))
            {
            TotalOrders+=1;
            }         
         }
      }
   return(TotalOrders);
   }
Subgenius
572
Subgenius 2015.09.07 00:15  
you must set account history to all history also
Keith Watford
Moderator
7963
Keith Watford 2015.09.07 05:00  
   int closed_orders=0;
   datetime today_midnight=TimeCurrent()-(TimeCurrent()%(PERIOD_D1*60));
   for(int x=OrdersHistoryTotal()-1; x>=0; x--)
      {
      if(OrderSelect(x,SELECT_BY_POS,MODE_HISTORY) && OrderCloseTime()>=today_midnight)
            closed_orders++;
      }
should do the trick
Sherif Hasan
7223
Sherif Hasan 2015.09.07 07:15  
GumRai:
should do the trick
Got it. Thanks to Subgenius n GumRaj
/
To add comments, please log in or register