I use Kim's function - open file - write a line - close the file and then go around.
//+------------------------------------------------------------------+ //| Запись строки в файл | //+------------------------------------------------------------------+ void WritingLineInFile(string FileName, string text) { int file_handle=FileOpen(FileName, FILE_READ|FILE_WRITE, " "); if (file_handle>0) { FileSeek(file_handle, 0, SEEK_END); FileWrite(file_handle, text); FileClose(file_handle); } }
live editing...
Thanks, it worked.
I also ran Kim's, but the string was different handle = FileOpen("Summa.txt", FILE_CSV|FILE_WRITE, '\t');
I use Kim's function - open file - write string - close file and then around.
do not want to check, but I think FileFlush() https://docs.mql4.com/ru/files/FileFlush should help not to close the file every time, if FileFlush() fixes the situation, it is better to open the file in init(), and close in deinit(), I did something similar, it seems adding once again FileWrite(file_handle, ""); will write a new line - that is, every FileWrite() is written with a new line - check it
ZS: I always write non-standard offline graphics without closing them, using FileFlush()
S)+";"+Do You can also make an empty array :) of 1 or 2 elements :) or add... +DoubleToStr(AccountEquity(),1)+"\r\n"; FileWrite(path, Symbol(), TimeToStr(TimeCurrent(),TIME_DATE),DoubleToStr(AccountBalance(),1), DoubleToStr(AccountEquity(),1),TimeToStr(TimeCurrent(),TIME_SECONDS)+"\r\n"); |
Hi all. I am trying to write each new order in a new line, could you tell me what I am doing wrong? Only the last open order remains.
void OnTick()

- AM2
- www.forexsystems.biz
Hi all. I am trying to write each new order in a new line, could you tell me what I am doing wrong? Only the last one opened remains written.
The file keeps getting overwritten because of wrong flags. You need to open the file not only for writing, but also for reading. Then it won't get recreated:
int h=FileOpen("Copy.txt",FILE_WRITE | FILE_READ,";");
The file is constantly being overwritten because of incorrect flags. You should not only open the file for writing, but also for reading. Then it won't get recreated:
Thank you very much. Thank you very much!
The description of the function itself contains this information, for some reason I missed it and didn't even know which way to go next... I thought I had selected a wrong file type, txt instead of csv, but it turned out to be very simple. )))
Can you tell me how to delete a line after reading it, is there any simple way to do it?

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Help me figure out how to write to a file.
Here's the function:
I need new data to be written on a new line in Excell, I've looked through all the code on the forum, including the tutorial and documentation, but no result :(((