Writing contents of frame to file

 

I've been trying to figure out how to write data during optimization into file for about a week.

I've tried paying people in Freelance section to figure it out. They don't understand it either.


I want to write data on every tick into the Frame() and then write all of the data into a file.


First I tried this method

Using this code

  

 


void OnTick()
{
 double bidPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Getting the Bid Price

         
   int hl=FileOpen("filetest",FILE_CSV|FILE_WRITE|FILE_SHARE_WRITE);
   if(hl==INVALID_HANDLE)
            {
            printf("Error %i creating tester file",GetLastError());
            }
   else
      {
      FileSeek(hl,0,SEEK_END); 
      FileWrite(hl,bidPrice);
      FileClose(hl);

      //--- Create a frame
    if(!FrameAdd("Statistics",bidPrice,0,"filetest"))
         printf("FrameAdd failed with error %i",GetLastError());
    else
             {
             Print("Frame added");
             }
       }
      
      
 }
   

but FileSeek does not work and it continuously re-writes the code on the first line.


Also using

      
   int hl=FileOpen("filetest.csv",FILE_CSV|FILE_WRITE|FILE_SHARE_WRITE);


does not work. It gives "file open error" when I do this. So it will only output to a file with no extension.


If I try to use this method 

I can store the frame data in the .mqd file 

But I can't figure out how to write the data into a file.


double bidPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID); // Getting the Bid Price
int data[];
   
void OnTick()
{
   
      //--- Create a frame
    if(!FrameAdd("Statistics",bidPrice,0,data))
         printf("FrameAdd failed with error %i",GetLastError());
    else
             {
             Print("Frame added");
             }
    
       }
      
      
 void OnTesterPass()
  
 { 
  int hl=FileOpen("filetest",FILE_CSV|FILE_WRITE);
      FileSeek(hl,0,SEEK_END);
      FileWrite (hl,data[0]);
      FileClose(hl);
      Print("pass");
 }
      


Can someone please help me solve this? I will pay if required.

 

Why opening a new thread ? You should use your previous one.

You are sending a frame on each tick, it's insane. You should collect your data, then send then with a frame at the end of the test.

 

I made a new thread because no one was responding to my other one.


I thought each frame was a packet of data? Then you call the frames into FileWrite()?

How can I collect data without sending into Frame()?

Why would I use Frame() at all if I can collect data without it?


Maybe I don't understand what Frame() does?


I can't find a good explanation anywhere on the internet.

 
Colin Leamy:

I made a new thread because no one was responding to my other one.


I thought each frame was a packet of data? Then you call the frames into FileWrite()?

How can I collect data without sending into Frame()?

Why would I use Frame() at all if I can collect data without it?


Maybe I don't understand what Frame() does?


I can't find a good explanation anywhere on the internet.

You need to understand how an optimization work to start, and then what Frames does.

Did you read this article for example ? There a lot of resources around optimization, passes and frames on this site.

Also you have to decide if you want to learn to do it yourself (so invest time) or to find someone to do it for you (invest money). I can't believe there is not one single freelancer able to do it.

MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
  • www.mql5.com
We continue the series of articles on MQL5 programming. This time we will see how to get results of each optimization pass right during the Expert Advisor parameter optimization. The implementation will be done so as to ensure that if the conditions specified in the external parameters are met, the corresponding pass values will be written to a file. In addition to test values, we will also save the parameters that brought about such results.
 
May I suggest to a moderator to merge both threads, we really don't need yet an other one about that topic.
 

I don't see anything in that article that explains to me why writing to frames on every tick is bad.

It says that frames store the data. So how can you store the data from every tick if you do not store it with frames?

As for the freelancing.

Maybe I'm just finding the wrong people in freelance, but the topic is an enigma to the people I've found so far.

If someone wants to recommend me someone I'd appreciate it.