Trying to write to file but it just creating blank file

 

I am trying to write SMA to file but it  doesn't write to file. Can someone please tell me what I am doing wrong here..Thanks a lot in advance


   double ma_0=iMA(Symbol(),PERIOD_D1,7,0,MODE_EMA,PRICE_CLOSE,0);
   string var1=TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);

   string filename = Symbol() + "_SMA" + "_" + Year() + Month() + Day() + "_myLog.txt";

   handle=FileOpen(filename, FILE_BIN|FILE_READ|FILE_WRITE);
   FileWrite(handle,"Symbol","Time");
    if(handle<1)
    {
     Print("can't open file error-",GetLastError());
     return;
    }
   FileSeek(handle, 0, SEEK_END);
   FileWrite(handle,Symbol(),var1,ma_0);
   FileClose(handle);
  return;
Documentation on MQL5: File Functions / FileWrite
Documentation on MQL5: File Functions / FileWrite
  • www.mql5.com
//|                                               Demo_FileWrite.mq5 | //|                        Copyright 2013, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | //| Script program start function                                    | //
 
try to change this:

 handle=FileOpen(filename, FILE_BIN|FILE_READ|FILE_WRITE);
   FileWrite(handle,"Symbol","Time");
    if(handle<1)
    {
     Print("can't open file error-",GetLastError());
     return;
    }

to

 handle=FileOpen(filename, FILE_TXT|FILE_WRITE);
    if(handle == INVALID_HANDLE)
    {
     Print("can't open file error-",GetLastError());
     return;
    }
   FileWrite(handle,"Symbol","Time");
Good luck.
Reason: