Is it really impossible to initialize external with a non constant ? - page 2

 

FG, try this

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
void start() {
  WriteDate(TimeCurrent()+PERIOD_D1*60);
  datetime MyDate = ReadDate();
  Comment(TimeToStr(MyDate,TIME_DATE|TIME_SECONDS));
}

datetime ReadDate(string sFile = "MyDateFile.txt") {
  int handle = FileOpen(sFile,FILE_CSV|FILE_READ);
  if(handle < 1 || FileSize(handle) == 0) return(0);
  datetime t = StrToTime(FileReadString(handle));
  FileClose(handle);
  return(t);
}

bool WriteDate(datetime MyDate, string sFile = "MyDateFile.txt") {
  int handle = FileOpen(sFile, FILE_CSV|FILE_WRITE);
  if(handle < 1) return(0);
  FileWrite(handle, TimeToStr(MyDate,TIME_DATE|TIME_SECONDS));
  FileClose(handle);
  return(1);
}
Reason: