void OnTimer() { if (RunEA && IsTradeAllowed()) { int handle=FileOpen("test.csv",FILE_READ|FILE_WRITE|FILE_CSV,";"); if(handle==INVALID_HANDLE){ Print("Error opening file. Error code: ",GetLastError()); return; } //THIS FIXES ERROR 5004 if (handle>0) //THIS FIXES ERROR 5004 { Print("File open"); FileWrite(handle,"Symbol","Ask","Bid"); //Name column headers FileSeek(handle, 0, SEEK_END); // go to end of file //Record Indicator values FileWrite(handle, Symbol(), Ask, Bid); FileClose(handle); //Close file } } }
The errors were because the file was already open.
Uhh yeah! You are so right :-)
Thanks!
Thanks!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi,
I just want to write some data to a csv. But I cannot see my mistake
I get error 5004 over and over again. It creates the file, but it's size=0.
The Timer is set to 5 sec.
the "int start()"-function doesn't help either.
Thanks in advance