Libraries: MultiTester - page 41

 
Sleep for 10 seconds doesn't help either. Only clearing that folder solves the problem.
 
klycko Sleep for 10 seconds doesn't help either. Only clearing that folder solves the problem.

Post the code for optimising MQL5\Experts\Examples\MACD\MACD Sample.mq5. Then you can try to reproduce it. There is almost no constructive work now.

 
fxsaber #:

Upload the code for optimising MQL5\Experts\Examples\MACD\MACD Sample.mq5. Then you can try to reproduce it. There is almost no constructive work now.

Thank you! I will try to prepare the files and post them. Right now everything is still in the untidy state.

 
fxsaber #:

Upload the code for optimising MQL5\Experts\Examples\MACD\MACD Sample.mq5. Then you can try to reproduce it. There is almost no constructive work now.

Good afternoon!

I have prepared the files and attached them.

Optimisation from 25.03 to 20.05.2024 on the timeframe M1.

Deposit 17000. Leverage 40. Maximum of the complex criterion.


First, for the purity of the experiment, we need to clear the folder "C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache".

The Nocturne script should be run one parameter at a time to optimise it.

Then it outputs:

On the first parameter: ProfitNow -1478 ParamMax 0.37 for the first time.

For the second parameter: ProfitNow -379 ParamMax 30 for the first time.

For the third parameter: ProfitNow -379 ParamMax 6 for the first time.


For the third parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly.


This shows the data cache hang-up on the third parameter.


And now we need to clear the folder "C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache" again

And then it's a repeat:


On the first parameter: ProfitNow -1478 ParamMax 0.37 for the first time.

For the second parameter: ProfitNow -379 ParamMax 30 for the first time.

For the third parameter: ProfitNow -379 ParamMax 6 for the first time.


For the third parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly


Lines 151-154 of the Nocturne script says everything as you instructed me:

Run(Odinar);

int GLOC = MTTESTER::GetLastOptCache(Bytes); // Get the opt file into a byte array Bytes

TESTERCACHE<ExpTradeSummary> Cache;

bool CL = Cache.Load(Bytes); // Feed the Bytes byte array into Cache


The bug is, of course, in the code I wrote, but I don't know how to fix it yet.

However, I have experimentally found that if you manually remove all opt files from the "C:\ bytes" folder before running Run.

from the "C:\Users\ASUSAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache" folder,

then my code works correctly and performs optimisation on the selected parameter.


If this folder is not cleaned, the Tester does not perform repeated optimisations (with the same unchanged data), but reads out

already existing opt-file from this folder. This can be clearly seen when repeatedly running the same optimisation manually.

It can be seen that the actual optimisation is only performed the first time, and then only reads the opt file from the folder.

This repeated reading does not seem to update the contents of the cache, and this is what is causing the error in my code.


Clearing said folder might help to resolve the error. Of course, this is a bad solution, and it would be more elegant to be able to restore the right data in the cache.

But I don't know how to do that. For now, the data from the previous real optimisation is hanging in the cache (not matching the re-read from the folder).

Unfortunately, this folder cannot be cleaned from the script using FolderClean, because it is forbidden in MQL5.

it is out of the "sandbox" and is filled only by the Strategy Tester.


Maybe you should create some external add-on by means of C++ and run it from the script.


Regards, Alexander

Files:
 

Error in the text:



Good afternoon!

Prepared the files and attached.

Optimisation from 25.03 to 20.05.2024 on the timeframe M1.

Deposit 17000. Leverage 40. Maximum of the complex criterion.


First, for the purity of the experiment, we need to clean the folder "C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache".

The Nocturne script should be run one parameter at a time to optimise it.

Then it outputs:

On the first parameter: ProfitNow -1478 ParamMax 0.37 for the first time.

For the second parameter: ProfitNow -379 ParamMax 30 for the first time.

For the third parameter: ProfitNow -379 ParamMax 6 for the first time.


For the first parameter: ProfitNow -379 ParamMax 6 repeatedly

For the second parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly.


This shows a data cache hang on the third parameter.


And now we need to clear the folder "C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache" again

And then it's a repeat:


On the first parameter: ProfitNow -1478 ParamMax 0.37 for the first time.

For the second parameter: ProfitNow -379 ParamMax 30 for the first time.

For the third parameter: ProfitNow -379 ParamMax 6 for the first time.


For the first parameter: ProfitNow -379 ParamMax 6 repeatedly

For the second parameter: ProfitNow -379 ParamMax 6 repeatedly

For the third parameter: ProfitNow -379 ParamMax 6 repeatedly.


Lines 151-154 of the Nocturne script says everything as you instructed me:

Run(Odinar);

int GLOC = MTTESTER::GetLastOptCache(Bytes); // Get the opt file into a byte array Bytes

TESTERCACHE<ExpTradeSummary> Cache;

bool CL = Cache.Load(Bytes); // Feed the Bytes byte array into Cache


The bug is, of course, in the code I wrote, but I don't know how to fix it yet.

However, I have experimentally found that if you manually remove all opt files from the "C:\ bytes" folder before running Run.

from the "C:\Users\ASUSAppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Tester\cache" folder,

then my code works correctly and performs optimisation on the selected parameter.


If this folder is not cleaned, the Tester does not perform repeated optimisations (with the same unchanged data), but reads out

already existing opt-file from this folder. This can be clearly seen when repeatedly running the same optimisation manually.

It can be seen that the actual optimisation is only performed the first time, and then only reads the opt file from the folder.

This repeated reading does not seem to update the contents of the cache, and this is what is causing the error in my code.


Clearing said folder might help to resolve the error. Of course, this is a bad solution, and it would be more elegant to be able to restore the right data in the cache.

But I don't know how to do that. For now, the data from the previous real optimisation is hanging in the cache (not matching the re-read from the folder).

Unfortunately, this folder cannot be cleaned from the script using FolderClean, because it is forbidden in MQL5.

it is out of the "sandbox" and is filled only by the Strategy Tester.


Maybe you should create some external add-on by means of C++ and run it from the script.


Regards, Alexander

 

I have posted my robot for optimisation, as Nocturne is oriented on its list of parameters.

But for MQL5\Experts\Examples\MACD\MACD Sample.mq5 it needs a lot of modification.


By the way, why do you need the parameter input int inNum = 0?

Or is it just an atavism?

 
fxsaber #:

Upload the code for optimising MQL5\Experts\Examples\MACD\MACD Sample.mq5. Then you can try to reproduce it. There is almost no constructive work now.

Good afternoon!

I managed to solve all my problems with the help of Alexander Slavsky: https://www.mql5.com/ru/users/s22aa.

He sent me the code for deleting Cache contents.

I couldn't clean Cache directly, as it is outside the sandbox.

Maybe it will be useful for someone before running the Run procedure, so that the results of past optimisations do not interfere with new ones.

I am attaching this script.

Your libraries and this cleanup procedure have ensured that I can consistently optimise the robot.

Thank you very much for these codes and your help.

Regards, Alexander

Aleksandr Slavskii
Aleksandr Slavskii
  • 2024.05.27
  • www.mql5.com
Профиль трейдера
Files:
 
klycko repeated optimisations (with the same unchanged data), but reads them out

already existing opt-file from this folder. This can be clearly seen when repeatedly running the same optimisation manually.

It can be seen that the real optimisation is done only the first time, and then only reads the opt file from the folder.

This repeated reading does not seem to update the contents of the cache, and this is what causes the error in my code.

sinput uint Range = 2;

void OnTesterInit( void )
{
  ::MathSrand((int)::TimeLocal());

  const int Start = ::MathRand();
  const int Step = ::MathRand();

  const uint TmpRange = (::Range < 2) ? 2 : ::Range;

  ::ParameterSetRange("Range", true, TmpRange, Start, Step, Start + (TmpRange - 1) * Step);
}
 
klycko #:

code for deleting the contents of the Cache.

In MTTester.mqh there is such a very demanded function when you make a lot of single runs.

  static bool DeleteLastTST( void )
  {
    const string Path = ::TerminalInfoString(TERMINAL_DATA_PATH)+ "\\Tester\\cache\\";
    string FileNames[];

    const int Size = MTTESTER::GetFileNames(Path, "*.tst", FileNames);

    return(Size && kernel32::DeleteFileW(Path + FileNames[Size - 1]));
  }

If you replace tst with opt, it will delete the last opt file. It seems redundant to clean the whole Cache folder.

 
Thank you!