Writing to file (Simple Noob question)

 
Hi all,
I just started working with MQL, I am playing around with it trying to figure out how things work, and I am trying to write my account information to a CSV file.

Here is the code I have:
int start()
  {
//----
   int fnum = FileOpen("testMQ4.txt",FILE_CSV|FILE_WRITE,",");
   if(fnum>0){
      FileWrite(fnum,TimeToStr(TimeLocal(),TIME_DATE|TIME_SECONDS), DoubleToStr(AccountBalance(),8),DoubleToStr(AccountCredit(),8),AccountCompany(),AccountCurrency(),AccountEquity(),AccountFreeMargin(),AccountLeverage(),DoubleToStr(AccountMargin(),8),AccountName(),AccountNumber(),AccountProfit(),AccountServer());
      FileClose(fnum);
   }



Now, when I attach this to a chart, it seems to run from the beginning of the chart, and ends up with a file that looks like this:

2007.04.13 22:59:59,10000.00000000,0.00000000,MIG Investments SA,USD,10000,10000,100,0.00000000,Lance Wynn,208209,0,MIG-Demo



(it is currently 2007.04.13 20:23:00) and the values for AccountMargin, and AccountEquity are not accurate to what I see in the client.

it seems like such a simple thing and I can't figure out what I am doing wrong. any nudges in the right direction are certainly appreciated.

Thanks
Lance

Reason: