You need move file position to the end of file after file opening. Use FileSeek function ("MQL4: FileSeek")
FileSeek(handle, 0, SEEK_END);
FileSeek(handle, 0, SEEK_END);
There is this line: FileDelete(filename);
Everytime you relaunch your EA, this line deletes your file.
Everytime you relaunch your EA, this line deletes your file.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.
So I use
hfile=FileOpen(filename,FILE_READ|FILE_WRITE,"\t");
to add data to the existing file.
But, if I re-launch my script, the previous data in the file (BarS1.txt) are lost.
What's wrong in my script?
How to keep previous data if I re-launch the script?
Do you have an idea?
Thanks.
CntBarOut.mq4 :