Good Afternoon !
Can someone please give a clue of the problem I am facing open the CSV file outside the regular MQL5 structure ?
filename returns C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\Common\Files\youbotg9.csv
fileHandle returns -1
Thank you very much
dont use whole addres, just use filename instead. Replace with this :
string filename = youbotg9.csv";
dont use whole addres, just use filename instead. Replace with this :
Belido,
Thank you for answering.
If I only use the filename, it will work but will save the file @ the regular MQL5 Terminal structure.
I need to save it in a public location since more MT5 instances will be looking for it.
Belido,
Thank you for answering.
If I only use the filename, it will work but will save the file @ the regular MQL5 Terminal structure.
I need to save it in a public location since more MT5 instances will be looking for it.
If you dont include the folder name, since you use |FILE_COMMON tag, it WILL write in C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\Common\Files\youbotg9.csv as your previous question. If I am not wrong, it wont write other then the common folder or MT5 folder itself.
Well ... Please accept my apologies but sometimes it does not work.
Two situations are happening now:
(1) When file does not exist, it gives me an error 5004 (File not found). I understand FileOpen() creates a file when it does not exist.
(2) When I manually create the file, script runs with no problems but writes nothing in the file.
When you run @ the regular MQL5 Files folder, it runs perfectly.
int fileHandle=FileOpen("youbotg9.csv",FILE_COMMON|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_CSV,","); if(fileHandle==INVALID_HANDLE) { Print("INVALID HANDLE: ",GetLastError()); ResetLastError(); } else { FileSeek(fileHandle,0,SEEK_END); FileWrite(fileHandle,"OFF"); FileClose(fileHandle); Print("FILE CREATED OFF"); }
Well ... Please accept my apologies but sometimes it does not work.
Two situations are happening now:
(1) When file does not exist, it gives me an error 5004 (File not found). I understand FileOpen() creates a file when it does not exist.
(2) When I manually create the file, script runs with no problems but writes nothing in the file.
When you run @ the regular MQL5 Files folder, it runs perfectly.
No problem
Perhaps you miss |FILE_WRITE and/or |FILE_READ tag. Just add this tag. It is not same with FILE_SHARE.
No problem
Perhaps you miss |FILE_WRITE and/or |FILE_READ tag. Just add this tag. It is not same with FILE_SHARE.
Working now !
The only thing that is not clear to me is keeping the file CSV file open while running the script to add ON and OFF makes no difference.
I understood we need FILE_SHARE to read/write the csv file to avoid getting an error while another instance of MT5 is using it.
Anyway ... You gave me a good start ... I will test tomorrow running with some MT5 instances to understand the difference between FILE and FILE_SHARE
Thank you very much for your attention.
Regards
Working now !
The only thing that is not clear to me is keeping the file CSV file open while running the script to add ON and OFF makes no difference.
I understood we need FILE_SHARE to read/write the csv file to avoid getting an error while another instance of MT5 is using it.
Anyway ... You gave me a good start ... I will test tomorrow running with some MT5 instances to understand the difference between FILE and FILE_SHARE
Thank you very much for your attention.
Regards

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good Afternoon !
Can someone please give a clue of the problem I am facing open the CSV file outside the regular MQL5 structure ?
filename returns C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\Common\Files\youbotg9.csv
fileHandle returns -1
Thank you very much