Saving variables in a csv file

 
I would like to save different variables at certain time intervals as they change in a csv file during a backtest of an expert advisor, so i could then anaylze it in excel. How can i do that?
 
See "MQL4: File functions"

FileOpen()
FileWrite()