Strategy Tester End Date - page 2

 
Henrique Vilela:

I could read it form the tester log. it register it like this:

But unfortunately it's outside de "file sandbox".

There's a solution that utilizes a symlink to that log folder. Basically you need to create a sticky folder in the file sandbox that holds the symlink - sticky in the way that it cannot be removed/cleaned up by the tester. Then during OnInit you make a local copy of that log to read out its testing end date. The setup is somewhat complicated but it works:

  1. In Tester\Agent-127.0.0.1-3000\MQL5\Files\ create a folder 'stay' (without the ' ' quotes)
  2. In this folder create a symlink by opening a cmd shell, cd into 'stay' and run: mklink /D testerlog ..\..\..\..\logs
  3. The symlink testerlog should now point to the \Tester\logs folder, you can check this by stepping into it.
  4. Remove rights to delete the 'stay' folder and its contents (steps see below *)
  5. Repeat this for all local agent directories. So if you got a quadcore this would be Agent-127.0.0.1-3001 Agent-127.0.0.1-3002 Agent-127.0.0.1-3003
  6. Add the code snippet below to your EA:
datetime TestingEndDate;

int OnInit()
  {
   if(MQLInfoInteger(MQL_TESTER))
     {
      if(!TesterGetEndDate()) return INIT_FAILED;
      Print("Testing from ",TimeCurrent()," to ",TestingEndDate);
     }
   ...
  }

bool TesterGetEndDate()
  {
   TestingEndDate=0;
   string filename;
   string filter="stay/testerlog/*.log";
   long hnd=FileFindFirst(filter,filename);
   if(hnd==INVALID_HANDLE) { Print("no files found, filter: ",filter); return false; }
   FileFindClose(hnd);
   if(!FileCopy("stay/testerlog/"+filename,0,filename,FILE_REWRITE)) { Print("copy "+filename+" failed"); return false; }
   int fh=FileOpen(filename,FILE_READ|FILE_TXT);
   if(fh==INVALID_HANDLE) { Print("failed to open "+filename); return false; }

   while(!FileIsEnding(fh))
     {
      string s=FileReadString(fh);
      if(StringFind(s,"testing of ")>0)
        {
         int pos=StringFind(s," to ");
         TestingEndDate=StringToTime(StringSubstr(s,pos+4));
        }
     }
   FileClose(fh);
   return TestingEndDate>TimeCurrent();
  }

And there you go.

* Steps to remove deletion rights from 'stay' folder:

  1. Open properties tab of folder, flip to Security, open Advanced
  2. Push 'Change access rights' button to get the Advanced Security settings for 'stay'
  3. Uncheck 'Inherit rights from parent object'. You will be prompted whether to remove or set all rights, choose remove all.
  4. Push the Add... button to select users or groups. There you push the Advanced... button to open a search dialog.
  5. Push the Search Now button to get a list of users. Scroll to find your username and select it. Confirm with OK.
  6. Back in the Advanced Security settings dialog, select your user and push Modify... to open a dialog with access rights.
  7. Check Full Access once just to flip all checks on, then remove these 3 rights by unchecking the checkbox: Full Access, Deletion, Deletion of subfolders and files
  8. Close all dialogs with OK. The folder should now show a small lock on it.
  9. That's all. You will be able to add but not delete files. If you need to delete anything in it, go to the security settings again and grant aforementioned rights by checking their checkboxes.
 
 

Did you find a way to get the "End Date" of the test?


Does anyone knows how to do that?

 
Guilherme Mendonca #:
 

Did you find a way to get the "End Date" of the test?


Does anyone knows how to do that?

Several solutions are proposed in the topic. Did you read and try them ?

There is no easy, standard mql way for sure.

 
Alain Verleyen #:

Several solutions are proposed in the topic. Did you read and try them ?

There is no easy, standard mql way for sure.

Hi Alain, 

Yes, I checked all the solution and there is no solution to get this information inside of (OnInitStart).

As the last message had more than 4 years, I thought someone else could give a different solution.

I'm sure Henrique Vilela (@Henrique Vilela) had a better solution, but unforntunately he disappeared without share with us.

 
Guilherme Mendonca #:

Hi Alain, 

Yes, I checked all the solution and there is no solution to get this information inside of (OnInitStart).

As the last message had more than 4 years, I thought someone else could give a different solution.

I'm sure Henrique Vilela (@Henrique Vilela) had a better solution, but unforntunately he disappeared without share with us.

You didn't read properly I think. Using a WinAPI call for example will allow you to do it (there is already a library to do that somewhere in the Codebase).

Most people here are only interested to grab information and never share anything, not a surprise.

 
Alain Verleyen #:

You didn't read properly I think. Using a WinAPI call for example will allow you to do it (there is already a library to do that somewhere in the Codebase).

Most people here are only interested to grab information and never share anything, not a surprise.


Ok Alain. I will search again in the Codebase.

Thank you for your response.

Reason: