Single array calculation during optimisation - page 3

 
forexman77:

The costs are greater unambiguously. There are two variants with unchanged indicator settings and with the same values, but already written to a file, which are dumped into an array.

The variant with the file takes many times longer to be calculated than the variant with indicator calculation in the Expert Advisor.

I was just thinking that maybe there is a way to save the array once and use it for all passes of optimization, thus relieving the load on the algorithm.

Is there a way to write and read the array that takes longer than the calculation of the indicator?

 
forexman77:
If you do this, will the array be saved when you switch to a new pass?
Yes, it must...
 
Dmitry Fedoseev:
Yes. It's not difficult or costly. You can use the binary mode. You may not read the entire file, but start from the position you need.
int init()
  {
   int k;
   string Skip;
   datetime Str_DtTm;
   double L;
   Handle=FileOpen(File_Name,FILE_CSV|FILE_READ|FILE_BIN,",");
   ResetLastError();
   if(Handle<0) // Failure when opening a file
     {
      if(GetLastError()==4103)
         Alert("There is no file named ",File_Name);
      else
         Alert("Error when opening a file ",File_Name);
      PlaySound("Bzrrr.wav");
      return(0);
     }
   ArrayInitialize(T,0);
   ArrayInitialize(dn,0);
   ArrayResize(T,stroki);
   ArrayResize(dn,stroki);
   for(k=stroki-1;k>=0;k--)
     {
      //--------------------------------------------------------- 5 --
      Str_DtTm=FileReadDatetime(Handle);// строка даты
      L=FileReadDouble(Handle);
      Skip=FileReadString(Handle);//пропускаем
      //--------------------------------------------------------- 6 -- 
      T[k]=Str_DtTm;   
      dn[k]=L;   
      //--------------------------------------------------------- 7 --
      if(FileIsEnding(Handle)==true){ Print("Конец отсчета=",TimeToString(T[k]));break;}//завершили отсчет

     }
   FileClose(Handle);

   return(0);
  }

Binary mode is when there are no line-to-number conversions?

I would also add that optimisation on a 1 minute chart on a large history.

 
include acts on compilation. Who is going to compile? Maybe this array depends on optimization parameters? So we have to generate the array before each optimization and compile it. It's a lame solution.
 
Dmitry Fedoseev:
include acts on compilation. Who is going to compile? Maybe this array depends on optimization parameters? So we have to generate the array before each optimization and compile it. It's a lame solution.
Don't make it up - TC clearly said that the array is unchanged.
 
forexman77:
Binary mode is when there is no string to number conversion?

https://www.mql5.com/ru/docs/files/filereadarray

https://www.mql5.com/ru/docs/files/filewritearray

The links have examples too.

 
Maxim Kuznetsov:
Don't make it up - the TC clearly said that the array is unchanged.
Unchanged during one optimization. There was nothing about the other invariance.
 
Of course, if the array is always and completely unchanged, it is better to include it in the EA code. You can include it directly in the EA file without including it.
 
Maxim Kuznetsov:
yes, you must...
Dmitry Fedoseev:
Of course, if the array is always and absolutely unchangeable, it's better to include it in the Expert Advisor's code. You can do it directly in the Expert Advisor's file without include.
I haven't encountered an include.Please direct me on how to do it approximately.
 
forexman77:
I haven't come across it yet. Point me in the right direction, how to do it roughly.
You can do it without the inlude, generate the array code with the script, write it to a file (you can also output it to Alert()), then transfer it to the EA code with the mouse.
Reason: