Day profits

 
How to calculate the totals profits of trading day ? Thank you in advance for your help
 
lucone wrote >>
How to calculate the totals profits of trading day ? Thank you in advance for your help
I used the following code:
double CalculateDayProfits()
{
double TotalDayProfits;
double CurrentProfits = AccountProfit();
double FixedProfits = 0;
string DateToday = StringSubstr(TimeToStr(TimeLocal()),0,10); //format "hhhh.mm.dd"
string DateCloseOrder;

int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)

if (OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==true)
{
DateCloseOrder =StringSubstr(TimeToStr(OrderCloseTime()),0,10); //format "hhhh.mm.dd"
if (DateCloseOrder == DateToday)
{
FixedProfits+=(OrderProfit());

}
TotalDayProfits=FixedProfits+CurrentProfits;
}

return(TotalDayProfits);

}
Reason: