How change row after FileOpen - FILE_WRITE ?

 

Hello, (first at all sorry for my not so correct English)

I'm using th function FileOpen and FileWrite like this codes:

  int filehandle=FileOpen("datosbloque2.csv",FILE_WRITE|FILE_CSV,"\t\r"); //  FILE datosbloque2.CSV
         if(filehandle!=INVALID_HANDLE)
         {
         FileWrite(filehandle,Symbol(),EnumToString(ENUM_TIMEFRAMES(_Period)),"startcycle",startHour,DoubleToString(openprice,5) ); // I WRITE VARIABLES IN FILE CSV
         FileClose(filehandle);
       //  Print("FileOpen OK");
         }

 Later if there are some condition I use this following code:

 

//RECORD DATA TO FILE datosbloques2.CSV
                                   int filehandle=FileOpen("datosbloque2.csv",FILE_WRITE|FILE_CSV,"\t\r"); //FILE datosbloque2.CSV
                                   if(filehandle!=INVALID_HANDLE)
                                      {
                                       FileWrite(filehandle,Symbol(),EnumToString(ENUM_TIMEFRAMES(_Period)),starthour,NormalizeDouble(open,5),NormalizeDouble(hhpoints,5),NormalizeDouble(hhporcentaje,4),"%",NormalizeDouble(llpoints,5),NormalizeDouble(llporcentaje,4),"%" );
                                       FileClose(filehandle);
                                      }
                                      else Print("Operation FileOpen failed, error ",GetLastError());


 But my problem is that every time I use this function (code) it create a new file and replace it. All this code is inside void OnTick {  } in my EA.

 I'd like to write data row after row in CSV file when I write on it.  (this is because i wrote "\t\r" )

file CSV 

 

Any idea?  Thank You !! 

 
Simo Dodero: Hello, (first at all sorry for my not so correct English)

I'm using th function FileOpen and FileWrite like this codes:

Later if there are some condition I use this following code:

But my problem is that every time I use this function (code) it create a new file and replace it. All this code is inside void OnTick {  } in my EA.

I'd like to write data row after row in CSV file when I write on it.  (this is because i wrote "\t\r" )

Any idea?  Thank You !! 

Read the following thread: https://www.mql5.com/en/forum/99755
How to keep previous data when open write and close?
How to keep previous data when open write and close?
  • www.mql5.com
Hi, I want to write an script which I should use file commands to store some data like names of stocks in it, but it will be overwritten everytime...
 
Fernando Carreiro:
Read the following thread: https://www.mql5.com/en/forum/99755
Thank You, I will read it !!!
Reason: