Get profit from specific time to specific time

 

Hello, I have code which gives me profit from specific time to today.

//--+ Get Profit From Specific time to Today +--//
double GetProfitFromDate(int month, int day){
   double   TimeProfit  = 0;
   datetime CurrentTime = TimeCurrent();
   datetime TimeFrom    = StringToTime((string)TimeYear(CurrentTime) + "." + month + "." + day);
   int      CandleFrom  = iBarShift(Symbol(), PERIOD_D1, TimeFrom);
   datetime GetTime     = iTime(Symbol(), PERIOD_D1, CandleFrom); 
   for(int xi=OrdersHistoryTotal()-1;xi>=0;xi--)
       { 
        if(!OrderSelect(xi,SELECT_BY_POS,MODE_HISTORY))continue;
        if(OrderCloseTime()<GetTime)break;
        if(OrderType()<2)TimeProfit+=OrderProfit()+OrderSwap()+OrderCommission(); 
       }  
   return(TimeProfit);
}

But I would like to get profit from specific time to specific time, like from 2020.11.30 to 2020.12.04

I tried some ways but couldn't do it. Any ideas? Or is it even possible?

 
mr-roma: But I would like to get profit from specific time to specific time, like from 2020.11.30 to 2020.12.04

That makes no sense. An order only has profit/loss at a market value, not time.

 

Well, actually I just found the way.

double Specific_Time_Profit = GetProfitFromDate(11,30) - GetProfitFromDate(12,07);

It works ....