trying to count total number of closed trades

 

trying to count total number of trades closed. but it shows twice the number for each trade. one when it opens and one as it closes. anyone can help please?


int TODAY_TRADES()
{
   datetime CurentTime = TimeCurrent(); 
   datetime PrevTime   = iTime(Symbol(),PERIOD_D1,0); 

   HistorySelect(PrevTime,CurentTime);
   int trades_of_day=0;

   int total=HistoryDealsTotal();
   
   
   return(total);
}
 

There are two deals involved with each trade. One to enter and the other to exit. You should count those exit deals.

int TodayRealizedCount()
{
   
   int count=0;
   datetime day_start=(int)(TimeCurrent()/(24*3600))*24*3600;

   if(HistorySelect(day_start, TimeCurrent()))
     {
      int total = HistoryDealsTotal();

      for(int i = 0; i < total; i++)
        {
         ulong dealTicket = HistoryDealGetTicket(i);

         if(HistoryDealGetInteger(dealTicket, DEAL_ENTRY) == DEAL_ENTRY_OUT)
           {
		count++;
           }
        }
     }
   return count;
}
 
Yashar Seyyedin #:

There are two deals involved with each trade. One to enter and the other to exit. You should count those exit deals.

Thank you brother