MQL4 - automated forex trading   /  

Documentation

MQL4 Reference  File functions  FileWrite

 
Use the opportunities of
MQL5 in MetaTrader 5
Study the new MQL5 language
Study the new MQL5 language.
Reference is already available
int FileWrite( int handle, ...)
The function is intended for writing of data into a CSV file, delimiter being inserted automatically. After writing into the file, the line end character "\r\n" will be added. Numbers will be converted into a text at output (see the Print() function).
Returns the count of written characters or a negative number if an error occurs.
To get the detailed error information, one has to call the GetLastError() function.
Parameters:
handle   -   File handle returned by the FileOpen() function.
...   -   User data to write, separated by commas. It can be up to 63 parameters.
Data of int and double types are automatically converted into a string, but those of color, datetime and bool typesare not automatically converted and will be written to file as they are (as integers).
Arrays cannot be passed as a parameter, they can be output elementwise.
Sample:
  int handle;
  datetime orderOpen=OrderOpenTime();
  handle=FileOpen("filename", FILE_CSV|FILE_WRITE, ';');
  if(handle>0)
    {
     FileWrite(handle, Close[0], Open[0], High[0], Low[0], TimeToStr(orderOpen));
     FileClose(handle);
    }