Hi,
This is driving me crazy but I have come to conclusion that you just cant use file access in the OnTester() function. But I hope I
am wrong and someone can help?
I am wanting to write data out as part of the Strategy
Tester Optimisation.
I can open and write to a file in both OnTesterInit() and OnTesterDeinit() functions. But putting exactly the same code in OnTester() and it just never does anything.
Below is the example code to prove it - 3 examples files opened and written too, but the OnTester() one never works .... the other two
work fine as expected.
Ideas anyone ? Am I missing something obvious or is this just not permitted to do File I/O in OnTester()
????
There is no problem to do file I/O in OnTester(). You probably just don't look in the right folder for your file. It's not the same place as with OnTesterInit(), which is standard MQL5/Files.
Use the FILE_COMMON flag or check in the right folder, mine is
"C:\Users\alain\AppData\Roaming\MetaQuotes\Tester\7F9D16CEFDFF2D39EA4EF8A208B4F896\Agent-127.0.0.1-3001\MQL5\Files"
Thanks for the reply.
Misread it originally as I do have two files already created correctly in the folder.
Would seem obvious to expect the 3rd one from the onTester() function to be placed in the same location.
Bizarre it isn't and written elsewhere. Not surprising people get confused as very inconsistent but sorted now.
Thanks once again for helping.
There is no problem to do file I/O in OnTester(). You probably just don't look in the right folder for your file. It's not the same place as with OnTesterInit(), which is standard MQL5/Files.
Use the FILE_COMMON flag or check in the right folder, mine is
"C:\Users\alain\AppData\Roaming\MetaQuotes\Tester\7F9D16CEFDFF2D39EA4EF8A208B4F896\Agent-127.0.0.1-3001\MQL5\Files"
If use FILE_COMMON flag, I want to output some self-defined test result to common folder, but it may has confict when mult test pass write to the same file.
Can I get the test passid in ea so that I can output to a special filename?
If use FILE_COMMON flag, I want to output some self-defined test result to common folder, but it may has confict when mult test pass write to the same file.
Can I get the test passid in ea so that I can output to a special filename?
You need to use Frames().
- 2017.01.03
- www.mql5.com
There is no problem to do file I/O in OnTester(). You probably just don't look in the right folder for your file. It's not the same place as with OnTesterInit(), which is standard MQL5/Files.
Use the FILE_COMMON flag or check in the right folder, mine is "C:\Users\alain\AppData\Roaming\MetaQuotes\Tester\7F9D16CEFDFF2D39EA4EF8A208B4F896\Agent-127.0.0.1-3001\MQL5\Files"
how do you know which folder to look at? I cannot also see the file. I debuggined handle is not -1 so it creates ok but I just do not see the file.
//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- static double lastHigh; static double lastLow; MqlRates priceInfo[]; ArraySetAsSeries(priceInfo, true); int priceData = CopyRates(_Symbol, _Period, 0, 3, priceInfo); if ((lastHigh != priceInfo[1].high) && (lastLow != priceInfo[1].low)) { int handle = FileOpen("aaa.csv", FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI); FileSeek(handle, 0, SEEK_END); FileWrite(handle, "Time", priceInfo[1].time); FileClose(handle); lastHigh = priceInfo[1].high; lastLow = priceInfo[1].low; Comment(priceInfo[1].high); } } //+------------------------------------------------------------------+
I also executed search on all computer by the file name , and it did not find it. How to understand?
Tried adding a breakpoint after file is created and searched whole computer and then found it. I do not get how earlier I could not find by searching all computer.
C:\Users\Darius\AppData\Roaming\MetaQuotes\Tester\9EB2973C469D24060397BB5158EA73A5\Agent-127.0.0.1-3000\MQL5\Files
I also have some problems writing files...
I use the COMMON option.
I've run my EA hundreds of times (in optimization mode), with my file correctly written each time. But suddenly it stopped working for some unknown reason (with no error message), and no way to get my EA to write another file with this MT
On other PCs it works fine.
I re-installed, and it works again, but I have to re-import all my symbols...
Any idea why? I would like to avoid having to completely re-import my symbols again.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
This is driving me crazy but I have come to conclusion that you just cant use file access in the OnTester() function. But I hope I am wrong and someone can help?
I am wanting to write data out as part of the Strategy Tester Optimisation.
I can open and write to a file in both OnTesterInit() and OnTesterDeinit() functions. But putting exactly the same code in OnTester() and it just never does anything.
Below is the example code to prove it - 3 examples files opened and written too, but the OnTester() one never works .... the other two work fine as expected.
Ideas anyone ? Am I missing something obvious or is this just not permitted to do File I/O in OnTester() ????