(Mq4) how to add information to a text file, line by line by using a script or EA? - page 2

 
puncher:

Thank you RaptorUK, I solve the problem - here's the solution I was looking for:

#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

int start()
  {

  int handle;
  handle=FileOpen ("plik_csv", FILE_CSV|FILE_WRITE|FILE_READ, ';');
  if(handle>0)
    {
     FileSeek(handle, 0, SEEK_END);
     FileWrite(handle, Symbol(), Close[0], Open[0], High[0], Low[0]);
     FileClose(handle);
    }

   return(0);
  }

SUBJECT IS CLOSED

SUBJECT IS CLOSED => LOL. Just trying to help. Since you show your codes, here's mine, and btw, you forget the file extension.

  string file_name = "Data for "+Symbol()+" of period "+Period();
  handle = FileOpen("test/"+file_name+".txt", FILE_CSV|FILE_WRITE|FILE_READ, ';');
  if(handle>0)
    {
    FileWrite(handle, "Bar #", "Symbol", "Close", "Open", "High", "Low", "Time");
    for (int pos = 0; pos < Bars; pos ++)
      {
      FileWrite(handle, pos, Symbol(), Close[pos], Open[pos], High[pos], Low[pos], TimeToStr(Time[pos], TIME_DATE|TIME_SECONDS));
      }
    FileClose(handle);
    }
  PlaySound("wait.wav");
 
//+------------------------------------------------------------------+
//|                                           zapis_do_pliku_csv.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {

//----

string sym=Symbol()+"_csv";
  int handle;
  datetime orderOpen=OrderOpenTime();
  handle=FileOpen(sym, FILE_CSV|FILE_WRITE, ';');
  if(handle>0)
    {
     FileWrite(handle, Symbol(), Close[0], Open[0], High[0], Low[0], TimeToStr(orderOpen));
     FileClose(handle);

    }
//----
   return(0);
  }

//+------------------------------------------------------------------+
I'm not one hundred percent sure of the code
Reason: