What did not work if your file is created ?
Alain Verleyen:
What did not work if your file is created ?
After I ran the EA the file is empty. No data is written. If I try to print out in the console everything is ok. P.S. MT5 is running on a virtual machine(VBOX) with winXP.
What did not work if your file is created ?
koralu:
After I ran the EA the file is empty. No data is written. If I try to print out in the console everything is ok. P.S. MT5 is running on a virtual machine(VBOX) with winXP.
After I ran the EA the file is empty. No data is written. If I try to print out in the console everything is ok. P.S. MT5 is running on a virtual machine(VBOX) with winXP.
You don't have to use these flags :
filehandle=FileOpen("1.csv",FILE_WRITE|FILE_READ|FILE_CSV|FILE_ACCESS_DATE|FILE_IS_WRITABLE|FILE_IS_READABLE);
and check the return value of FileWrite().
Alain Verleyen:
I removed the flags and the return value of FileWrite() function is 64. As I read in the manual this is the number of bytes written and the file is still empty. But what am I concerned is when I change the name of the file to a non existing one the "filehandle" variable is still 1 and the return value of fileWrite() is still 64.
You don't have to use these flags :
and check the return value of FileWrite().
koralu:
I removed the flags and the return value of FileWrite() function is 64. As I read in the manual this is the number of bytes written and the file is still empty. But what am I concerned is when I change the name of the file to a non existing one the "filehandle" variable is still 1 and the return value of fileWrite() is still 64.
I removed the flags and the return value of FileWrite() function is 64. As I read in the manual this is the number of bytes written and the file is still empty. But what am I concerned is when I change the name of the file to a non existing one the "filehandle" variable is still 1 and the return value of fileWrite() is still 64.
If the file doesn't exist it's created, please read the documentation carefully.
Anyway, I tried your code and it works. Attached the file created.
Files:
1.zip
1 kb
Alain Verleyen:
Thank you for your time Alain. The problem was solved and I shame on me because I didn't read carefully the documentation. In the testing mode the file is created in other directory than MQL5/files.....as it said in the manual: (or testing_agent_directory\MQL5\files in case of testing).
If the file doesn't exist it's created, please read the documentation carefully.
Anyway, I tried your code and it works. Attached the file created.
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
Hello,
I made a simple EA to write something in a file just for the sake of example but it didn't work.
void OnTick()
{
int filehandle;
filehandle=FileOpen("1.csv",FILE_WRITE|FILE_READ|FILE_CSV|FILE_ACCESS_DATE|FILE_IS_WRITABLE|FILE_IS_READABLE);
if(filehandle!=INVALID_HANDLE)
{
ResetLastError();
FileWrite(filehandle,TimeCurrent()," - ",Symbol());
Print ("err ",GetLastError()); ResetLastError();
FileClose(filehandle);
Print("FileOpen OK");
}
}
I got no errors and the "FileOpen Ok" message is written. My csv - "1.csv" is in MetaTrader 5\MQL5\Files
Also I noted that if I change the name of csv in my code from "1.csv" to "blabla.csv" I also got no errors. It's very weird and I can't figure out what I'm missing.
Can you help me with some advices?