work with file: text in columns

 

how do I write the table title with the corresponding values


bool writeFile()
  {
  
     string       nomeFileTXT   = "ottimizzazione.txt";
   bool printOK = false;

   int filehandle;
   int errore=0;     // numero dell'errore
   uint numBytesWritten=0;
   string stringa;

  //
   filehandle=FileOpen(nomeFileTXT,FILE_READ|FILE_WRITE|FILE_CSV);
   // If a file has been opened successfully, the function returns the file handle, which is then used to access the file data. In case of failure returns INVALID_HANDLE.
   if(filehandle==INVALID_HANDLE)   // Incorrect handle = -1 : errore nella creazione del file
     {
      errore = GetLastError();
      Alert(__FUNCTION__," (",__LINE__,"):   Errore #"+IntegerToString(errore)+" "+" nel tentativo di apertura del file "+nomeFileTXT);
      // FileClose(filehandle);  è inutile cercare di chiudere un file che non è stato aperto ed il cui filehandle=-1 per cui FileClose(filehandle) non sortisce effetto!
      return(false);
     }
   else  if (printOK)   Print(__FUNCTION__," (",__LINE__,"):   filehandle = "+IntegerToString(filehandle));
FileWrite(filehandle,
           "MaxOrder",
     "TeckProfit", 
     "StopLoss",
     "TF_",
     "PeriodsADXEntry",
     "LivelADXEntry",
      "PeriodsADXExit",
     "LivelADXExit",
  "exit",
  "entry",
  "periodMA1",
  "periodMA2",

        "FromHours1",
 "FromToUntilHours1",
        "FromHours2",
 "FromToUntilHours2",
        "FromHours3",
 "FromToUntilHours3",
        "FromHours4",
 "FromToUntilHours4", 
       "parametro1", "parametro2", "parametro3", "parametro4"); // il file viene inizializzato
   FileSeek(filehandle, 0, SEEK_END);     // si porta il puntatore alla fine del file, così da inserire la nuova riga di dati per la barra i-esima
   //uint numBytesWritten = FileWrite(filehandle, "#", "Takeprofit", "Stoploss", "ProfitLoss_Pip", "contaBarre", "Profit_Pip", "numTradeInProfit", "(numTradeInProfit/contaBarre)*100", "Loss_Pip", "numTradeInLoss", "(numTradeInLoss/contaBarre)*100", "valorMedioPip_escursioneMax", "numPip_escursioneMax");
   numBytesWritten = FileWrite(filehandle,
     MaxOrder,
     TeckProfit, 
     StopLoss,

  TF_,
       PeriodsADXEntry,
     LivelADXEntry,
    PeriodsADXExit,
     LivelADXExit,
  exit,
  entry,
  periodMA1,
  periodMA2,

        FromHours1,
 FromToUntilHours1,
        FromHours2,
 FromToUntilHours2,
        FromHours3,
 FromToUntilHours3,
        FromHours4,
 FromToUntilHours4,  
    DoubleToString(parametro1,2), DoubleToString(parametro2,2), DoubleToString(parametro3,2), DoubleToString(parametro4,5));


   if(numBytesWritten==0)
     {
      errore = GetLastError();
      Alert(__FUNCTION__," (",__LINE__,"):   Errore #"+IntegerToString(errore)+" "+" nel tentativo di scrittura sul "+nomeFileTXT);
      FileClose(filehandle);
      return(false);
     }
   else
     {
      if (printOK)
        {
         Print(__FUNCTION__," (",__LINE__,"):   Scritta una riga di parametri di sintesi nel file "+nomeFileTXT);
         Print(__FUNCTION__," (",__LINE__,"):     questo file ha Filesize="+IntegerToString(FileSize(filehandle))+"   dopo aver scritto "+IntegerToString(numBytesWritten)+" bytes");
        }
      FileClose(filehandle);
      return(true);
     }
  }

MaxOrder TeckProfit StopLoss TF_ PeriodsADXEntry LivelADXEntry PeriodsADXExit LivelADXExit exit entry periodMA1 periodMA2 FromHours1 FromToUntilHours1 FromHours2 FromToUntilHours2 FromHours3 FromToUntilHours3 FromHours4 FromToUntilHours4 parametro1 parametro2 parametro3 parametro4

20 20 70 3 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -275.00 389.50 0.00000
70 20 70 3 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -275.00 389.50 0.00000
20 70 70 3 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -275.00 389.50 0.00000
70 70 70 3 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -275.00 389.50 0.00000
20 20 20 4 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -231.00 324.00 0.00000
70 20 20 4 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -231.00 324.00 0.00000
20 70 20 4 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -231.00 324.00 0.00000
70 70 20 4 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -231.00 324.00 0.00000
20 20 70 4 6 15 6 15 4 1 6 6 0 0 0 0 0 0 0 1 0.00 -231.00 324.00 0.00000
70 20 70 4 6 15 6 15 4 1 6