blocked script after 21hrs : can because of how I read time ?

fw1555
18

i am unsure why my script gets blocked after ~21 hours.

it runs every 3 seconds or 5 minutes.


kindly please advise, especially if there is a way to debug and find where the code is getting blocked and potentially why ! 


One thought:

https://www.mql5.com/en/docs/predefined/_stopflag

The _StopFlag variable contains the flag of the mql5-program stop. When the client terminal is trying to stop the program, it sets the _StopFlag variable to true.


how can the client terminal trying to stop the program ? why ?

This example is terrifying :)) - could someone elaborate how this works ?

https://www.mql5.com/en/docs/basis/operators/for

or it may be because I use the Alert function instead of Comment ? and the window is crashing ??

My high level code structure looks like this (it has few thousands lines of code):


#definition vars

int OnStart(){

while(true)
analysis: for 1
exec orders: for2

}

i use GetTickCount() or GetMicrosecondCount() as variable control relative to time.
When i was using just Sleep () things were not getting stuck (as I recall - but can't go back to that... too infantile)
all variables are declared properly (ulong, uint, int, double and so on...)


Documentation on MQL5: Predefined Variables / _StopFlag
Documentation on MQL5: Predefined Variables / _StopFlag
  • www.mql5.com
The _StopFlag variable contains the flag of the mql5-program stop. When the client terminal is trying to stop the program, it sets the _StopFlag variable to true.
fw1555
18
fw1555  

i believe this code was the issue. isolated problem !!!


it is used in a while loop with a sleep sequence with 3 or 5 seconds. after about 1350 minutes - the script get blocked.



  fileName = Symbol()+ "Detailed" + Period()+".csv"; // analiza pe fiecare symbol
  fileHandle = FileOpen(fileName,FILE_CSV|FILE_READ | FILE_WRITE);
  
  fileReport = "AllLogsReports"+".csv";
  fileRHandle = FileOpen(fileReport,FILE_CSV|FILE_READ | FILE_WRITE);
  FileSeek(fileRHandle,0, SEEK_END);
  data = "DayofYear"+ "," + currentTime.day_of_year + "," + "Hour" + "," + currentTime.hour + "," + "Minute" + "," + currentTime.min;
  FileWrite (fileRHandle, data);
  
  fileDominance = "DominanceHistory"+".csv";
  fileDHandle = FileOpen(fileDominance,FILE_CSV|FILE_READ|FILE_WRITE);
  FileSeek(fileDHandle,0, SEEK_END);
  data = "DayofYear"+ "," + currentTime.day_of_year + "," + "Hour" + "," + currentTime.hour + "," + "Minute" + "," + currentTime.min;
  //FileWrite (fileDHandle, data);
  
  FileSeek(fileHandle, 0, SEEK_END); // Write at the end of the file.




   FileClose(fileHandle); // inchidere fisier de lucru
   FileClose (fileRHandle); 
   FileClose (fileDHandle);