1) which kind of file (format) should be used (maybe .CSV?).
2) would it be possible to store and recall string values?
3) how exactly could this function be called and the data file be restored, once we don't have inside FrameNext the possibility to use data files?
You create a file.
FrameAdd() call send the file in MQL5\Files (related to your terminal, in case you are using external agents).
TesterPass event is generated and OnTesterPass() handler called. Here you just have to open the file with FileOpen() and read your data.
Any file, a file is a file.
You can use any data.
You create a file.
FrameAdd() call send the file in MQL5\Files (related to your terminal, in case you are using external agents).
TesterPass event is generated and OnTesterPass() handler called. Here you just have to open the file with FileOpen() and read your data.
Hi Alain,
I'm not sure about what you posted... You can try yourself... try, for instance, to add a simple string array to FrameAdd:
string data[2];
data[0] = "test_0";
data[1] = "test_1";
//---
FrameAdd("stats",1,0,data);
Then you get an error message:
That's why I'm trying to export string values to a data file. However, when you use, for instance,
{
Print("Error while loading data file");
}
it fails somehow while loading the data file.
Regarding the third question, I would like to be able to import the optimization data using dataframes, as I would like to be able to sepparate data for each pass. And this cannot be done if I export everything to the same file, as I cannot get the pass id inside the optimization itself.
So I think the 3 questions above are still open... :-)
Regards,
Malacarne
Hi Alain,
I'm not sure about what you posted... You can try yourself... try, for instance, to add a simple string array to FrameAdd:
string data[2];
data[0] = "test_0";
data[1] = "test_1";
//---
FrameAdd("stats",1,0,data);
Then you get an error message:
That's why I'm trying to export string values to a data file. However, when you use, for instance,
{
Print("Error while loading data file");
}
it fails somehow while loading the data file.
Regarding the third question, I would like to be able to import the optimization data using dataframes, as I would like to be able to sepparate data for each pass. And this cannot be done if I export everything to the same file, as I cannot get the pass id inside the optimization itself.
Of course, what is the problem ? Create your data file in OnTester(). Declare it with FrameAdd().
Inside OnTesterPass() open your data file and process it, in the same way you did with an array.
So I think the 3 questions above are still open... :-)
Regards,
Malacarne
No it's not open :-) You are searching for complex things when in fact it's really simple.
EDIT: Well after some checking it's seems not so easy :-D
What is the result of the request to the service desk? I'm about to ask the same question.
For me, only binary file can be transferred. Text file is submitted to FrameAdd without an error, but receiving end gets an array full of zeros from FrameNext.
What is the result of the request to the service desk? I'm about to ask the same question.
For me, only binary file can be transferred. Text file is submitted to FrameAdd without an error, but receiving end gets an array full of zeros from FrameNext.
I checked against following your post and finally figured out how it works :
//+------------------------------------------------------------------+ //| Optimization start | //+------------------------------------------------------------------+ void OnTesterInit() { //--- If writing of optimization results is enabled Print(__FUNCTION__,"(): Start Optimization \n-----------",TerminalInfoString(TERMINAL_DATA_PATH)); } //+------------------------------------------------------------------+ //| Test completion event handler | //+------------------------------------------------------------------+ double OnTester() { //--- If writing of optimization results is enabled int hl=FileOpen("filetest",FILE_CSV|FILE_WRITE); if(hl==INVALID_HANDLE) { printf("Error %i creating tester file",GetLastError()); } else { int rndval=MathRand(); FileWriteString(hl,StringFormat("this is a random test %i",rndval)); FileClose(hl); //--- Create a frame if(!FrameAdd("Statistics",rndval,0,"filetest")) printf("FrameAdd failed with error %i",GetLastError()); else { Print("Frame added"); } } //--- return(0.0); } //+------------------------------------------------------------------+ //| Next optimization pass | //+------------------------------------------------------------------+ void OnTesterPass() { ulong pass; string name; long id; double value; ushort data[]; if(!FrameNext(pass,name,id,value,data)) printf("Error #%i with FrameNext",GetLastError()); else printf("%s : new frame pass:%llu name:%s id:%lli value:%f",__FUNCTION__,pass,name,id,value); string receivedData=ShortArrayToString(data); printf("Size: %i %s",ArraySize(data),receivedData); Comment(receivedData); } //+------------------------------------------------------------------+ //| End of optimization | //+------------------------------------------------------------------+ void OnTesterDeinit() { Print("-----------\n",__FUNCTION__,"(): End Optimization"); }Thanks @Stanislav Korotky
I checked against following your post and finally figured out how it works :
Do you receive zeros as well? What is your output?
No, as I said it works, not for you ?
2017.05.21 20:00:48.107 FrameTest (EURUSD,M6) OnTesterInit(): Start Optimization
2017.05.21 20:00:57.292 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:0 name:Statistics id:28820 value:0.000000
2017.05.21 20:00:57.292 FrameTest (EURUSD,M6) Size: 28 this is a random test 28820
2017.05.21 20:00:57.309 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:16 name:Statistics id:28820 value:0.000000
2017.05.21 20:00:57.309 FrameTest (EURUSD,M6) Size: 28 this is a random test 28820
...
2017.05.21 20:01:10.587 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:79 name:Statistics id:8492 value:0.000000
2017.05.21 20:01:10.587 FrameTest (EURUSD,M6) Size: 27 this is a random test 8492
2017.05.21 20:01:10.720 FrameTest (EURUSD,M6) -----------
2017.05.21 20:01:10.720 FrameTest (EURUSD,M6) OnTesterDeinit(): End Optimization
No, as I said it works, not for you ?
2017.05.21 20:00:48.107 FrameTest (EURUSD,M6) OnTesterInit(): Start Optimization
2017.05.21 20:00:57.292 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:0 name:Statistics id:28820 value:0.000000
2017.05.21 20:00:57.292 FrameTest (EURUSD,M6) Size: 28 this is a random test 28820
2017.05.21 20:00:57.309 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:16 name:Statistics id:28820 value:0.000000
2017.05.21 20:00:57.309 FrameTest (EURUSD,M6) Size: 28 this is a random test 28820
...
2017.05.21 20:01:10.587 FrameTest (EURUSD,M6) OnTesterPass : new frame pass:79 name:Statistics id:8492 value:0.000000
2017.05.21 20:01:10.587 FrameTest (EURUSD,M6) Size: 27 this is a random test 8492
2017.05.21 20:01:10.720 FrameTest (EURUSD,M6) -----------
2017.05.21 20:01:10.720 FrameTest (EURUSD,M6) OnTesterDeinit(): End Optimization

- 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 all,
According to the MQL5 Official Documentation, the FrameAdd function can be called using two different sets of parameters.
The second one is actually easy to handle, as passing the data to an array is quite simple.
However, I'm interested in the first method, where, according to the Docs, it would be possible to pass optimization data to a data file.
I couldn't find neither in the Docs nor in the MQL5.com English Forum any single reference of how to use this function through a data file.
In the case, I would like to know three things:
1) which kind of file (format) should be used (maybe .CSV?).
2) would it be possible to store and recall string values?
3) how exactly could this function be called and the data file be restored, once we don't have inside FrameNext the possibility to use data files?
Thanks in advance for any help!
Malacarne