A question on FileWrite functions.

 

Morning all,

Quick question on the FileWrite() function; I currently have a FileWrite() function in my EA to a CSV-formatted spreadsheet, which works perfectly, however, is there a way in which you can write data to a spreadsheet template and to a certain cell reference within that spreadsheet?

For example, I want to calculate the standard deviation (I know MQL4 has a standard deviation indicator but quite frankly, I don't like it) of a number of prices which I have allocated to cell B5 through to cell to B15, could I alter my FileWrite() function so that MQL4 can write those prices to those particular cells in a templated spreadsheet?

The below code is used in conjunction with the OrderSelect function (Don't worry about the //Append File functions themselves, these will be altered.).

Just to be clear, not asking anyone to implement this into my code, as this is what the Freelancer section is for.  

//Create File
   string   mySpreadSheet = "closed_orders.csv";
   
      //Open File
      int file_handle = FileOpen(mySpreadSheet, FILE_READ |FILE_WRITE | FILE_CSV | FILE_ANSI);
      
         if(file_handle != INVALID_HANDLE){
         
            //Go to the end of the file
            FileSeek(file_handle, 0, SEEK_END);
               
               //Append File
               payee             =  "<company name>";
               description       =  "Sale";
               reference         =  "Revenue";
               chequeNo          =  "00000000";
               comment           =  "No Comment";
               thisAccountNumber =  AccountNumber();
               
                  //Append File
                  FileWrite(file_handle, "AccountNumber",thisAccountNumber,"*Date", comment ," *Amount", OrderProfit(), " Payee", payee, " Description", description," Reference", reference, " Cheque Number", chequeNo); 
                  
                     //Close File
                     FileClose(file_handle);
                     
                        Print("File Entry Written");
                        
                           BarTime = Time[0];
                           
                              return;
                              
         } else {
         
            lastErrorCode =  (IntegerToString(GetLastError()));
            
               Print("Invalid File Handle. Report error "+(lastErrorCode));
         
         }
 
TheHonestPrussian: you can write data to a spreadsheet template and to a certain cell reference within that spreadsheet?

No. Best you can do is write a CSV file and import it.

 
William Roeder #:

No. Best you can do is write a CSV file and import it.

Thanks William