Features of the mql5 language, subtleties and tricks - page 285

 
Aleksey Vyazmikin #:

What's your favourite activity?

For obvious reasons, he won't answer.
But I'll be cheeky and answer it for him.
Saber is not a programmer. There are many programmers. There are very few algorithm developers, or those with architected skills working at a higher level of abstraction. They like to invent but do not like to code, although they can do it sometimes better than professional programmers. Programming is just a toolkit for them. They almost never take up the implementation of other people's ideas that are below the level of their ideas.
 
Nikolai Semko #:
For obvious reasons, he won't answer.
But I'll be brave enough to answer it for him.
Saber is not a programmer. There are plenty of programmers. There are very few algorithm developers, or those with architected skills working at a higher level of abstraction. They like to invent but do not like to code, although they can do it sometimes better than professional programmers. Programming is just a toolkit for them. They almost never take up the implementation of other people's ideas that are below the level of their ideas.

As I understood, most of portal's participants are not certified programmers but have learnt the language out of necessity.

But maybe a person has a completely different interest not related to the market, and for him the market is a tool....

 
Offtopic
 

If the Expert Advisor uses data from a file, there are several ways to pass it to the Agents.

Each has its pros and cons, so let's also measure the efficiency in case of optimisations.

For this purpose, I enabled seven local Agents on the mat. mode, sandboxes of which are located on RAMDrive.


Cloud - tester_file.
.

#define  FILENAME "Ticks.bin" // https://www.mql5.com/ru/forum/478178/page10#comment_55702486

#property tester_no_cache
#property tester_file FILENAME

input int inRange = 0;

double OnTester()
{
  MqlTick Ticks[];
  
  return(FileLoad(FILENAME, Ticks) ? ArraySize(Ticks) : -1);
}


Efficiency.

optimization finished, total passes 1000
optimization done in 0 minutes 30 seconds
shortest pass 0:00:00.078, longest pass 0:00:00.234, average pass 0:00:00.192
local 1000 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)


Local Agents - COMMON-file.
.

#define  FILENAME "RamDriveFolder\\Ticks.bin" // https://www.mql5.com/ru/forum/478178/page10#comment_55702486

#property tester_no_cache

input int inRange = 0;

double OnTester()
{
  MqlTick Ticks[];
  
  return(FileLoad(FILENAME, Ticks, FILE_COMMON) ? ArraySize(Ticks) : -1);
}


Efficiency.

optimization finished, total passes 1000
optimization done in 0 minutes 27 seconds
shortest pass 0:00:00.143, longest pass 0:00:00.300, average pass 0:00:00.179
local 1000 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)


Local Agents - #resource.
.

#resource "Ticks.bin" as MqlTick Ticks[] // https://www.mql5.com/ru/forum/478178/page10#comment_55702486

#property tester_no_cache

input int inRange = 0;

double OnTester()
{
  return(ArraySize(Ticks));
}


Efficiency.

optimization finished, total passes 1000
optimization done in 0 minutes 00 seconds
shortest pass 0:00:00.000, longest pass 0:00:00.000, average pass 0:00:00.000
local 1000 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)


Bottom line.

Efficiency.

tester_file COMMON-file #resource
30 seconds 27 seconds

0 seconds

If you need it fast and without Cloud - #resource is the most efficient way to transfer data to Agents.

Other options are terribly slow even on RAMDrive, because allocating memory for a dynamic data array on each pass is very expensive.


If you need a lot of data, it is quite ambiguous that it makes sense to mess with the Cloud.


OnTester results on all variants coincided - 1368151. Just in case the cache was manually deleted before launching.

 
fxsaber #:

Need fast and no Cloud - #resource is the most efficient way to transfer data to Agents.

Unfortunately, in addition to the size limit (sizeof(#resource) < 128Mb) recompilation is required with new data as it is stitched into EX5.

If you need a lot of data, it is quite ambiguous that it makes sense to mess with the Cloud.

The resources will work in the Cloud because the data is stitched in.
 
It turns out that there is no fast way to work with a tick array in the matrix mode. For example, your tester in the matrix mode will be inferior in speed to your tester in the normal mode, because the latter does not spend resources to create and transfer the initial tick array.
 

Forum on trading, automated trading systems and testing trading strategies

Peculiarities of mql5 language, subtleties and techniques of work

fxsaber, 2025.01.22 11:09 AM

Cloud - tester_file.

#define  FILENAME "Ticks.bin" // https://www.mql5.com/ru/forum/478178/page10#comment_55702486

#property tester_no_cache
#property tester_file FILENAME

input int inRange = 0;

double OnTester()
{
  MqlTick Ticks[];
  
  return(FileLoad(FILENAME, Ticks) ? ArraySize(Ticks) : -1);
}


Efficiency.

optimization finished, total passes 1000
optimization done in 0 minutes 30 seconds
shortest pass 0:00:00.078, longest pass 0:00:00.234, average pass 0:00:00.192
local 1000 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)

Why the hell the following change speeds up optimisation almost three times!

#define  FILENAME "Ticks.bin" // https://www.mql5.com/ru/forum/478178/page10#comment_55702486

#property tester_no_cache
#property tester_file FILENAME

input int inRange = 0;

MqlTick Ticks[2000000];

double OnTester()
{
//  MqlTick Ticks[];
  
  return(FileLoad(FILENAME, Ticks) ? ArraySize(Ticks) : -1);
}
optimization finished, total passes 1000
optimization done in 0 minutes 12 seconds
shortest pass 0:00:00.009, longest pass 0:00:00.114, average pass 0:00:00.080
local 1000 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)


Why does FileLoad to a dynamic array run slower than to a static array?

 
fxsaber #:

Why the hell does the next change speed up optimisation by almost three times!


Why is FileLoad to a dynamic array slower than to a static array?

I'll assume that the global array is allocated once, since the Expert Advisor is loaded once (unless the ExpertRemove function was called).

The dynamic array will be allocated on each pass.

 
Stanislav Korotky #:

I assume that the global array is allocated once, because the Expert Advisor is loaded once (unless the ExpertRemove function was called).

The dynamic array will be allocated on each pass.

It's a pity that working with data in mat mode is more theory than practice.

 
fxsaber #:

Why is FileLoad to a dynamic array slower than to a static array?

I think, just not optimal reserve in ArrayResize is used inside FileLoad.