- My MT4 folder has above 60GB capacity - question
- MQL5: Clearing the [Expert] Tab window via MQL5 script / EA
- How to write new line in binary file?
I've setup verbose logging on my EA for troubleshooting purposes. I'd like to track each iteration in the same file but when I do FileClose and reopen the file on the next iteration it clears the file. How do I write new lines in the same file, preferably text?
https://docs.mql4.com/files/FileOpen:
'If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.'
You'll need to move the file pointer to the end of file with FileSeek() before appending the new data.
https://docs.mql4.com/files/FileOpen:
'If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.'
You'll need to move the file pointer to the end of file with FileSeek() before appending the new data.
This is what I have right now, I'm getting a FileWrite Error:
string textfile=StringConcatenate(Symbol(),"_logging.txt");
int logging=FileOpen(textfile,FILE_READ || FILE_WRITE);
if(count<0)
{
if(logging>0)
{
FileSeek(logging, 0, SEEK_END);
FileWrite(logging,"No open orders for pair..");
FileClose(logging);
}
else
{
Print("File issue");
}
}
else
{
if(logging>0)
{
FileSeek(logging, 0, SEEK_END);
FileWrite(logging,"Order in progress..");
FileClose(logging);
}
else
{
Print("File issue");
}
}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use