weekly code not work

 
void SetReportDates()

{

   ushort sep;

   sep=StringGetCharacter(",",0);

   //StringSplit(Symbols,sep,selectedSymbols);

   

   startDate = TimeLocal();

       

   if(reportType == "Daily")

   {

      MqlDateTime start_date_struct;

      TimeToStruct(startDate,start_date_struct);

      start_date_struct.hour = 0;

      start_date_struct.min = 0;

      start_date_struct.sec = 1;

      

      

      MqlDateTime end_date_struct = start_date_struct;

      end_date_struct.hour = 23;

      end_date_struct.min = 59;

      end_date_struct.sec = 59;

      

      

      startDate = StructToTime(start_date_struct);

      endDate = StructToTime(end_date_struct);

   }

   

   if(reportType == "Weekly")

   {

      MqlDateTime start_date_struct;

      TimeToStruct(startDate,start_date_struct);

      start_date_struct.day = start_date_struct.day -7;

      start_date_struct.hour = 0;

      start_date_struct.min = 0;

      start_date_struct.sec = 1;

      

      

      

      

      endDate = startDate;

      

      MqlDateTime end_date_struct;

      TimeToStruct(endDate,end_date_struct);

      end_date_struct.hour = 0;

      end_date_struct.min = 0;

      end_date_struct.sec = 0;

      endDate=StructToTime(end_date_struct);

      

      startDate = StructToTime(start_date_struct);

   }

   

   if(reportType == "Monthly")

   {

      MqlDateTime start_date_struct;

      TimeToStruct(startDate,start_date_struct);

      start_date_struct.hour = 0;

      start_date_struct.min = 0;

      start_date_struct.sec = 0;

      

      MqlDateTime end_date_struct = start_date_struct;

      

      start_date_struct.mon = start_date_struct.mon -1;

      start_date_struct.day = 1;

      

      end_date_struct.mon = end_date_struct.mon -1;

      

      if(start_date_struct.mon == 4 || start_date_struct.mon == 6 || start_date_struct.mon == 9 || start_date_struct.mon == 11)

         end_date_struct.day = 30;

      else if(start_date_struct.mon == 2)

         end_date_struct.day = 28;

      else

         end_date_struct.day = 31;    

            

      endDate = StructToTime(end_date_struct);

      startDate = StructToTime(start_date_struct);

   }

}







void WriteReport()

{

   CFileTxt htmlFile;

   htmlFile.Open(reportFileName + ".html",FILE_WRITE);

   htmlFile.WriteString(reportContent);

}



void WriteTableRow(string &columns_names[], int &columns_sizes[])

{

   string col_header;

   for (int c=0; c<ArraySize(columns_names);c++)

   {

      

      int col_header_fill = columns_sizes[c]-StringLen(columns_names[c]);

      for (int i=0;i<col_header_fill;i++)

         col_header += " ";

      col_header = col_header += columns_names[c];

   }



   reportContent += col_header+"\n";

}



void GenerateReport()

{

   reportContent = "";

   

   int totalOrders = 0;

   double totalPips = 0;

   

   ushort sep;

   sep=StringGetCharacter(",",0);

   

   ArrayResize(values,3);

   ArrayResize(sizes,3);

   StringSplit("SYMBOL,ORDERS,PROFIT-pips",sep,values);

Hallo 

I had this code to send me daily , weekly and monthly closing order pips

daily is work perfect but weekly not work neither monthly too 

 
      start_date_struct.day = start_date_struct.day -7;
Which start_date_struct do you think you referencing, the one inside the weekly if, or the one outside?
 
William Roeder:
Which start_date_struct do you think you referencing, the one inside the weekly if, or the one outside?

Hi

I want to get report in Friday evening 22/5/2020 

for example I want from 18/5/2020  to 22/5/2020

also in 

31/5 

I get report from 1/5 till 31/5 

Reason: