Hello everybody
I just tried to write a Little script:
//+------------------------------------------------------------------+ //| Write Data.mq5 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.MQL5.com" #property version "1.00" void OnStart() { string filename="F:\\Example.txt"; //FIlename?? Filefolder?? int file_handle=FileOpen(filename,FILE_READ|FILE_WRITE|FILE_TXT); for(int i=0;i<20;i++) //Counting from i=0 to i=20 { FileWrite(file_handle,i,i+2,i+10); //Write to file; i i+2 i+10 } FileClose(file_handle); //Close the File }
can anyone help me?
thx
ok thank you ... next time i will do it with the SRC Button...
But you cant help me with my Problem?
Hello everybody,
i just started Prgramming with MQL5.
At the Moment i'm trying to write some Datas to a .txt file. (not complex)
i have got some Problems:
1. In which Folder do have to create the file?
The documentation tells you . . . FileOpen()
"For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox.
The file is opened in the folder of the client terminal in the subfolder MQL5\files (or testing_agent_directory\MQL5\files in case of testing). If FILE_COMMON is specified among flags, the file is opened in a shared folder for all MetaTrader 5 client terminals."
Hello everybody,
2. How do i have to program the "script" to make sure the Datas are saved in the file?
FileWrite() will return the value of the number of items written . . . if you want to be fully sure read back the file contents and compare them against what you think you should have written.
Thank you for your answer. I just found the MQL5 Folder. It was the one in the testing...Directory. That was the Problem, i allways searched in the normal program data Folder.
Thank you for your answer. I just found the MQL5 Folder. It was the one in the testing...Directory. That was the Problem, i allways searched in the normal program data Folder.


- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody,
i just started Prgramming with MQL5.
At the Moment i'm trying to write some Datas to a .txt file. (not complex)
i have got some Problems:
1. In which Folder do have to create the file?
2. How do i have to program the "script" to make sure the Datas are saved in the file?
I just tried to write a Little script:
//+------------------------------------------------------------------+
//| Write Data.mq5 |
//| Copyright 2013, MetaQuotes Software Corp. |
//| http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.MQL5.com"
#property version "1.00"
void OnStart()
{
string filename="F:\\Example.txt"; //FIlename?? Filefolder??
int file_handle=FileOpen(filename,FILE_READ|FILE_WRITE|FILE_TXT);
for(int i=0;i<20;i++) //Counting from i=0 to i=20
{
FileWrite(file_handle,i,i+2,i+10); //Write to file; i i+2 i+10
}
FileClose(file_handle); //Close the File
}
can anyone help me?
thx