iTime format: from integer to date

To add comments, please log in or register
Manuel Sanchon
1084
Manuel Sanchon  

Hi all, 

I write a file in an expert with timestamp, OHLC and Volume obtaining something like: 1522101000,1.24556,1.24559,1.24546,1.24557,126

I would like to have something like: 2018.03.27 21:53:00,1.24556,1.24559,1.24546,1.24557,126

Here is the code:

int handle_write = FileOpen( StringConcatenate( Symbol(), "_newdata.csv" ),FILE_CSV|FILE_WRITE, ',');
if ( handle_write > 0 ) 
  {
  FileSeek( handle_write, 0, SEEK_END ); 


  for(int Count = n_minutes; Count >= 1 ; Count--)
         {
                FileWrite( handle_write,
                  iTime ( Symbol(), Period(), Count ),
                  iOpen ( Symbol(), Period(), Count ),
                  iHigh ( Symbol(), Period(), Count ),
                  iLow  ( Symbol(), Period(), Count ),
                  iClose( Symbol(), Period(), Count ),
                  iVolume( Symbol(),Period(), Count ));
         }

  FileClose( handle_write );
  //Print("Temporal info written...", iTime ( Symbol(), Period(), Count ));
}

How to obtain date format instead integers (this version is part of an expert, previously I had an indicator with exactly the same code that worked well)?


Thanks in advance

William Roeder
20228
William Roeder  
Perhaps you should read the manual.
Converting a value containing time in seconds elapsed since 01.01.1970 into a string of "yyyy.mm.dd hh:mi" format.
          TimeToString - Conversion Functions - MQL4 Reference
To add comments, please log in or register