Help about FileWrite...

To add comments, please log in or register
Murat Yazici
1521
Murat Yazici  

Hi all,

I am a new one on the mql4 programer. I try to write an EA. I have a table called updated_Q with 6*6 matrix (updated_Q[6][6]. This table is updated in EA according to some rules.
I want to write it my file called updated_Q as csv. However, I don't know how I can do this. Can you help me please?


I read filewrite function but I couldn't do it exactly. Where should I keep the updated_Q file. And, How can I update it?

Best,

Murat 

nicholi shen
2392
nicholi shen  
Murat Yazici:

Hi all,

I am a new one on the mql4 programer. I try to write an EA. I have a table called updated_Q with 6*6 matrix (updated_Q[6][6]. This table is updated in EA according to some rules.
I want to write it my file called updated_Q as csv. However, I don't know how I can do this. Can you help me please?


I read filewrite function but I couldn't do it exactly. Where should I keep the updated_Q file. And, How can I update it?

Best,

Murat 

The file will have to be saved to your MQL4/Files directory and this is how I like to write csv files, but there are other ways.

#include <Files\File.mqh>
void OnStart(){
   int matrix[3][3] = {
      {1,2,3}, 
      {4,5,6}, 
      {7,8,9}
   };
   CFile file;
   if(file.Open("matrix.csv", FILE_TXT|FILE_WRITE) == INVALID_HANDLE)
      return;
   string csv_str = "";
   for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
         csv_str += string(matrix[i][j]) + ",";
      }
      csv_str += "\n";
   }
   FileWriteString(file.Handle(), csv_str);
}
Murat Yazici
1521
Murat Yazici  
nicholi shen:

The file will have to be saved to your MQL4/Files directory and this is how I like to write csv files, but there are other ways.

Thank you so much @nicholi shen !!

Best.

To add comments, please log in or register