Remove first line in output file

 

Hi friends,

I have this code: 

//+------------------------------------------------------------------+
//|                                                           Dd.mq5 |
//|                                                  ParsinaTejaratt |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "ParsinaTejaratt"
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   //---- 
   int handle;
   int cnt;
   int _year = 2002;
   int _month = 1;
   int _day = 1;
   string strline;
   string name_file;
   int DailyLength = 16408;
   int idxCounter = 1000;
   
   //-- define the variable "rates"
   MqlRates rates [];
   //-- elements will be indexed like in timeseries.
   ArraySetAsSeries(rates,true);
   //-- Get the  history data of current symbol. (first point is present)
   int copied=CopyRates(Symbol(),Period(),0,idxCounter,rates);
   if(copied>0)
   {
   name_file = StringSubstr(Symbol(), 0, 1) + StringSubstr(Symbol(), 1, 1) + StringSubstr(Symbol(), 2, 1)+StringSubstr(Symbol(), 3, 1)+StringSubstr(Symbol(), 4, 1)+ StringSubstr(Symbol(), 5, 1)+ "-" + PeriodConvertor(Period())+ ".prn";
   //Print("name_file=", name_file);
   //FILE_CSV|FILE_WRITE
   handle = FileOpen(name_file , FILE_WRITE|FILE_ANSI , "\t");
   if(handle<1)
      {
      Print("can't open file error-",GetLastError());
      return(0);
      }
   strline = "<DTYYYYMMDD>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>";
   FileWrite(handle, strline);
   
   int size=fmin(copied,idxCounter);
   for (cnt=size-1;cnt>=0;cnt--)
      {
      if (Period() < DailyLength)
         {
         
         strline = DoubleToString(_year,0);
         if (_month < 10)
            strline = strline + "0" + DoubleToString(_month,0);
         else
            strline = strline + DoubleToString(_month,0);
      
         if (_day < 10)
            strline = strline + "0" + DoubleToString(_day,0);
         else
            strline = strline + DoubleToString(_day,0);          
         }
      else
         {
         strline = TimeToString(rates[cnt].time,TIME_DATE|TIME_SECONDS);
         strline = StringSubstr(strline,0,4) + StringSubstr(strline,5,2) + StringSubstr(strline,8,2);
         //Print("strline=", strline);
         }
      strline = strline + ",0," + DoubleToString(rates[cnt].open,4) + "," + DoubleToString(rates[cnt].high,4) + "," + DoubleToString(rates[cnt].low,4) + "," + DoubleToString(rates[cnt].close,4) + "," + DoubleToString(rates[cnt].tick_volume,0);
      FileWrite(handle, strline);
      // Start of build virtual date.
      if (Period() < DailyLength)
         {
         if (_day < 28) 
            _day++; 
         else 
            {
            _day = 1;
            _month++;
            if (_month > 12)
               {
               _month = 1;
               _year++;
               }
            }
         }
      // End of build virtual date.
      }
   FileClose(handle);
   }//end if copied
//----
   return(0);
  }
  
  string PeriodConvertor(ENUM_TIMEFRAMES tf)
  {
     switch(tf)
        {
         case 1: return "M1";
         case 2: return "M2";
         case 3: return "M3";
         case 4: return "M4";
         case 5: return "M5";
         case 6: return "M6";
         case 10: return "M10";
         case 12: return "M12";
         case 15: return "M15";
         case 30: return "M30";
         case 16385: return "H1";
         case 16386: return "H2";
         case 16387: return "H3";
         case 16388: return "H4";
         case 16390: return "H6";
         case 16392: return "H8";
         case 16396: return "H12";
         case 16408: return "D1";
         case 32769: return "W1";
         case 49153: return "MN1";
         }
     return (string)tf;
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+


In output I want to remove first Line of this "<DTYYYYMMDD>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>" . 

When I remove this line, I have first line empty and I do not want it. 

Would you please help me how can I do that.

Thanks.

Files:
EX-H4.txt  55 kb
 

What did you try and what did cause the result above?

Because I think you only need to delete the following two lines.

Line 42-43.

//strline = "<DTYYYYMMDD>,<TIME>,<OPEN>,<HIGH>,<LOW>,<CLOSE>,<VOL>";
//FileWrite(handle, strline);
 
int OnInit(){
   MqlRates rates [];
Don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
  1. Terminal starts.
  2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
  3. OnInit is called.
  4. For indicators OnCalculate is called with any existing history.
  5. Human may have to enter password, connection to server begins.
  6. New history is received, OnCalculate called again.
  7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Reason: