need help: problem in write/read

 

asked here also : https://www.mql5.com/en/forum/86907

HI. I try it as below,

can you please check this part of code;

i have store data in "  write " part and they are true and i have the file .(have problem about time )

then i want to read them in " read " part and when i print them on chart have problem for time : the part have time parameter highlighted have problem .( i think)

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int      filehandleWRITE_BUY;
string   filenameWRITE_BUY;
//++++++++
int      filehandleREAD_BUY;
string   filenameREAD_BUY;
//+++++++++++++++++++++


int      LEVEL_WRITE_BUY[26];
double   PRICE_WRITE_BUY[26];
datetime TIME_WRITE_BUY[26];
double   LOW_WRITE_BUY[26];
double   TP_BUY=0;
int      LEVEL_READ_BUY[26];
double   PRICE_READ_BUY[26];
datetime TIME_READ_BUY[26];
double   LOW_READ_BUY[26];

//----------------------------------------------------------------------------------------------------------//
void OnTick(void)
  {
//----------------------------------------------------------------------------------------------------------//
 .
//------------------------------------------------------------------------------------------  FILE WRITE
   filenameWRITE_BUY = AccountInfoInteger(ACCOUNT_LOGIN)+"_BUY_"+_Symbol+".csv";
   filehandleWRITE_BUY = FileOpen(filenameWRITE_BUY,FILE_WRITE|FILE_CSV);

//--- 
   //string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   //string filename=terminal_data_path+"\\MQL5\\Files\\"+"fractals.csv";
//---
   ResetLastError();
   if(filehandleWRITE_BUY!=INVALID_HANDLE)
     {    
       for(int wr = 0; wr < 26; wr++)
          {
           //  TimeCurrent:  ", TimeToStr(TimeCurrent() - 7200, TIME_MINUTES|TIME_SECONDS),TimeToString
           FileWrite(filehandleWRITE_BUY, LEVEL_WRITE_BUY[wr], PRICE_WRITE_BUY[wr], (TimeToStr(TIME_WRITE_BUY[wr]-7200 , TIME_MINUTES|TIME_SECONDS)), LOW_WRITE_BUY[wr]);
           FileFlush(filehandleWRITE_BUY);
          }
       //FileFlush(filehandleWRITE_BUY);
       //--- close the file
       FileClose(filehandleWRITE_BUY);
       PrintFormat("Data is written, %s file is closed",filenameWRITE_BUY);

     }
   else Print("PROBLEM TO SEND TXT FILE! Error = ",GetLastError());
//----------------------------------------------------------------------//
//------------------------------------------------------------------------------------------  FILE READ

   ResetLastError();
   //--- open the file
   filenameREAD_BUY =AccountInfoInteger(ACCOUNT_LOGIN)+"_BUY_"+_Symbol+".csv";
   filehandleREAD_BUY=FileOpen(filenameREAD_BUY,FILE_READ|FILE_CSV); // ,FILE_READ|FILE_ANSI);
   
   if(filehandleREAD_BUY!=INVALID_HANDLE)
     {
      PrintFormat("%s file is available for reading",filenameREAD_BUY);
      PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
      
      //  TimeCurrent:  ", TimeToStr(TimeCurrent() - 7200, TIME_MINUTES|TIME_SECONDS),TimeToString
      int wr1 = 0;
      while(!FileIsEnding(filehandleREAD_BUY))
      //for(int wr1 = 0; wr1 < 26; wr1++)     
      /*
           {
            LEVEL_READ_BUY[wr1]=(FileReadInteger(filehandleREAD_BUY));
            PRICE_READ_BUY[wr1]=(FileReadDouble(filehandleREAD_BUY));
            TIME_READ_BUY[wr1]=(FileReadDatetime(filehandleREAD_BUY));
            LOW_READ_BUY[wr1]=(FileReadDouble(filehandleREAD_BUY));
            wr1++;
            continue;
           }
      */
   
      {
            LEVEL_READ_BUY[wr1]=StrToInteger(FileReadString(filehandleREAD_BUY));
            PRICE_READ_BUY[wr1]=StrToDouble(FileReadString(filehandleREAD_BUY));
            //TIME_READ_BUY[wr1]=StrToTime(FileReadString(filehandleREAD_BUY));
            TIME_READ_BUY[wr1]=StringToTime(FileReadString(filehandleREAD_BUY));
            LOW_READ_BUY[wr1]=StrToDouble(FileReadString(filehandleREAD_BUY));
            if(FileIsLineEnding(filehandleREAD_BUY)) {wr1++;continue;}
           }
   
      //--- close the file
       FileClose(filehandleREAD_BUY);
       PrintFormat("Data is READED, %s file is closed",filenameREAD_BUY);
     }
     else PrintFormat("%s FAILED ! file is not available for reading",filenameREAD_BUY,GetLastError());
//---
   
   
//----------------------------------------------------------------------------------------------------------//

*** )   " PROBLEM IS IN ' TIME ' WRITE~READ  :"

can you please check it to see what is wrong .

thank you.
 

What is the problem?

Telling us that you have a problem, tells us nothing.

Explain what you mean by "problem"

 

i run it on strategy tester , as you see the reading time is 2 hour less than the stored in write.

and if remove the "7200" in the first highlighted line time wll be the current time as below picture:

in real time chart as below:


also in strategy tester as below:

----------------------------------------------------------------------------------------------------------------------------------------------------

2-) the csv file :

3th column is time : ( is look blank )


 
Don't use a spreadsheet, that's just adding another layer of misdirection. Show the file contents, command line/type or notepad.
 

problem solved: in first highlighted line :

(TimeToString(TIME_WRITE_BUY[wr] , TIME_DATE|TIME_SECONDS))
Reason: