FileWrite only in one cell

 

Hi all,

I'm writing a CSV filewrite feature in my EA to basically track my equity curve as well as other data. 

This code works but everything is printed in one cell, rather than a different column for each parameter - any ideas?

   if(new_bar(PERIOD_M5))
     {
      string csv_name = "Infinity Journal.csv";
      int csv_handle = FileOpen(csv_name,FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI);
      FileSeek(csv_handle,0,SEEK_END);
      FileWrite(csv_handle," Time: ",TimeCurrent()," Total Pips: ",DoubleToString(total_pips,1)," Total Profit: ",DoubleToString(total_profit,2)," Profit per Pip: ",DoubleToString(total_profit/total_pips,2)," % Change: ",DoubleToString(change,2)," Gain: ",DoubleToString(gain,2));
      FileClose(csv_handle);
     }


 
Benjamin David Hardman:

Hi all,

I'm writing a CSV filewrite feature in my EA to basically track my equity curve as well as other data. 

This code works but everything is printed in one cell, rather than a different column for each parameter - any ideas?


Looking into it more it looks to be a problem with excel as if I open with numbers (mac) it works fine:


 
Benjamin David Hardman: rather than a different column for each parameter - any ideas?
      int csv_handle = FileOpen(csv_name,FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI);

Perhaps you should specify a separator (in the code and corresponding in Excel).

 
William Roeder #:

Perhaps you should specify a separator (in the code and corresponding in Excel).

Yep that did it! Thanks William


int csv_handle = FileOpen(csv_name,FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI,',');