Running MetaTester agent under restricted Windows user

 

On the page https://www.metatrader5.com/en/terminal/help/algotrading/testing there is the following text: “Participation in MQL5 Cloud Network is absolutely safe.

Clearly that’s not the case, because the MetaTester program install agents (Windows services), which run under the SYSTEM user. Although the agents run MQL5 code in a sandbox (according to the MQL5 Cloud FAQ), this does not imply that the sandbox is flawless. As part of the MQL5 Cloud Network the agents can be accessed by practically everyone. It is a bad practice to run a publicly accessible network service under a user who has administrative privileges and it is misleading to say that this is absolutely safe situation.

I’m trying to configure MetaTester agents to run under restricted Windows user. So far I did the following (on Windows 7 and Windows 8 machines):

  1. I created a Windows user which I’ll call here MT and which is not explicitly member of any group.
  2. I granted MT Full control permission to the subfolder Tester of the folder in which MetaTester64.exe is located.
  3. I changed the user under which the MetaTester services run via the Services snap-in (services.msc).
I added agents configured in that way as remote agents in my MetaTrader console and successfully used them for testing of Expert Advisors. However these agents failed to process jobs from the MQL5 Cloud.

I would like to know:

  1. What permissions an agent needs in order to process a job from the MQL5 Cloud?
  2. Is there a way to make more detailed the logging of agent activity?
  3. Is there a way to check the ability of an agent to process jobs from the MQL5 Cloud for a reasonable amount of time (i.e. within 30 minutes)?
Here are parts of the log file of one of the agents:

KS     0      15:13:33     Network      connected to 1.agents.mql5.com

LF     0      15:13:34     Network      authorized on 1.agents.mql5.com

MN     0      15:13:34     Network      38680 bytes of group info loaded

IF     0      15:13:34     Network      1490 bytes of tester parameters loaded

OI     0      15:13:34     Network      3268 bytes of input parameters loaded

FQ     0      15:13:34     Network      220 bytes of symbols list loaded

OJ     0      15:13:34     Tester job 5905636961791516629 received from Cloud Server

IO     0      15:13:34     Tester file added, 16570 bytes loaded

PI     0      15:13:34     Network      2268 bytes of optimized inputs info loaded

HM     0      15:13:34     Tester successfully initialized

RD     0      15:13:34     Network      29 Kb of total initialization data received

MP     0      15:13:34     Tester [Hardware specification]

NF     0      15:13:34     Tester optimization pass 1791141 started

OM     2      15:13:34     Tester loading of ditrade (USDCHF,H1) failed

JG     3      15:13:34     Tester working time at stop is 16 ms

NM     0      15:13:34     Tester tester agent shutdown

HI     0      18:04:38     Network      connected to 1.agents.mql5.com

EL     0      18:04:39     Network      authorized on 1.agents.mql5.com

FE     0      18:04:41     Network      38680 bytes of group info loaded

KN     0      18:04:41     Network      1490 bytes of tester parameters loaded

EJ     0      18:04:41     Network      94404 bytes of input parameters loaded

OP     0      18:04:41     Network      220 bytes of symbols list loaded

ES     0      18:04:41     Tester job 5905682046063244317 received from Cloud Server

PL     0      18:04:41     Tester file added, 1330696 bytes loaded

ES     0      18:04:41     Tester job 5905682046063244317 received from Cloud Server

PP     0      18:04:41     Tester file added, 10738 bytes loaded

QR     0      18:04:41     Tester job 5905682046063244317 received from Cloud Server

RG     0      18:04:41     Tester file added, 50035 bytes loaded

MR     0      18:04:41     Tester job 5905682046063244317 received from Cloud Server

KJ     0      18:04:41     Tester file added, 4274 bytes loaded

EL     0      18:04:41     Network      126104 bytes of optimized inputs info loaded

JD     0      18:04:41     Tester successfully initialized

QR     0      18:04:41     Network      1586 Kb of total initialization data received

MH     0      18:04:41     Tester [Hardware specification]

DO     0      18:04:41     Tester optimization pass 290928688 started

MG     2      18:04:41     Tester loading of multi_expert_system_trading_way (USDJPY,M30) failed

FS     3      18:04:41     Tester working time at stop is 15 ms

DF     0      18:04:41     Tester tester agent shutdown


 

Hi ianev,

I am not a specialist for agents and cloud sorry (i am just using cloud for optimization). But it is what I found (and in this artricle as well)

Forum

Discussion of article "Speed Up Calculations with the MQL5 Cloud Network"

Rosh, 2012.02.20 09:00

You should read the article The Fundamentals of Testing in MetaTrader 5:

The Data Exchange between the Terminal and the Agent

...

The agents never record to the hard disk the EX5-files, obtained from the terminal (EA, indicators, libraries, etc.) for security reasons, so that a computer with a running agent could not use the sent data. All other files, including DLL, are recorded in the sandbox. In remote agents you can not test EAs using DLL.

The testing results are added up by the terminal into a special cache of results (the result cache), for a quick access to them when they are needed. For each set of parameters, the terminal searches the result cache for already available results from the previous runs, in order to avoid re-runs. If the result with such a set of parameters is not found, the agent is given the task to conduct the testing.

All traffic between the terminal and the agent is encrypted.



 
newdigital:

Hi ianev,

I am not a specialist for agents and cloud sorry (i am just using cloud for optimization). But it is what I found (and in this artricle as well)


I read the relevant parts of that article. They do not give adequate answers to the stated questions. There is a mismatch between the said location for storing historical data from the article and the actual location of that data.

Today one of my agents recorded the following in its log:

NN     0      09:43:56     Network      connected to 3.agents.mql5.com

PI     0      09:43:56     Network      authorized on 3.agents.mql5.com

DS     0      09:43:57     Network      38680 bytes of group info loaded

PE     0      09:43:57     Network      1490 bytes of tester parameters loaded

GQ     0      09:43:57     Network      23236 bytes of input parameters loaded

IJ     0      09:43:57     Network      791 bytes of symbols list loaded

NM     0      09:43:57     Tester job 5906669901426208676 received from Cloud Server

LH     0      09:43:57     Tester file added, 209270 bytes loaded

LM     0      09:43:57     Tester job 5906669901426208676 received from Cloud Server

PG     0      09:43:57     Tester file added, 5151 bytes loaded

FM     0      09:43:57     Tester job 5906669901426208676 received from Cloud Server

MJ     0      09:43:57     Tester file added, 10757 bytes loaded

JM     0      09:43:57     Tester job 5906669901426208676 received from Cloud Server

JJ     0      09:43:57     Tester file added, 10657 bytes loaded

NL     0      09:43:57     Tester job 5906669901426208676 received from Cloud Server

NG     0      09:43:57     Tester file added, 3946 bytes loaded

FO     0      09:43:57     Network      29724 bytes of optimized inputs info loaded

FD     0      09:43:57     Tester successfully initialized

KK     0      09:43:57     Network      297 Kb of total initialization data received

LS     0      09:43:57     Tester [Hardware specification]

PF     0      09:43:57     Tester optimization pass 1094 started

GO     0      09:43:57     Symbols      EURUSD: symbol to be synchronized

LH     0      09:43:57     Symbols      EURUSD: symbol synchronized, 3304 bytes of symbol info received

HO     0      09:44:03     History      EURUSD: load 8326 Kb of history data to synchronize

GN     0      09:44:03     History      EURUSD: history synchronized from 2007.01.01 to 2011.04.29

RF     0      09:44:03     History      EURUSD,M1: contains 305015 bars of beginning data from 2007.01.01 00:06 to 2007.12.31 18:00

HI     0      09:44:03     History      EURUSD,M1: history cache reserved for estimated 1626171 bars

EP     0      09:44:03     History      EURUSD,M1: history begins from 2007.01.01 00:06

PK     2      09:44:03     Tester tester stopped because OnInit reports Tester Agent is not suitable

PK     3      09:44:03     Tester working time at stop is 343 ms

QG     0      09:44:03     Tester tester agent shutdown


So apparently a MQL5 program succeeded to start and execute code from its OnInit function. What it considered for unsuitable is not clear.

The computer on which my MetaTester agents run is less than a year old and it fulfills the criteria for participation in the MQL5 Cloud with exception of the PR based criteria (I don’t know the PR of my agents, because none of them is listed in my profile).

Is there a way to calculate or estimate manually the PR of a MetaTester agent?

 
ianev:

I read the relevant parts of that article. They do not give adequate answers to the stated questions. There is a mismatch between the said location for storing historical data from the article and the actual location of that data.

Have you read built-in terminal Help - https://www.metatrader5.com/en/terminal/help/start_advanced/start

Start Terminal

After the installation has been completed, a group of the client terminal programs is created in the "Start" menu, and the program shortcut is additionally located on the desktop. They will help to start the client terminal.

Two copies of the Client Terminal are prohibited to be started from the same directory simultaneously. To start several terminals simultaneously, it is necessary to install the corresponding amount of programs in different directories.

There are two main modes of client terminal launch, as well as several additional modes described in a separate section.

Main Mode

By default, the terminal is installed to /Program Files/terminal folder/, to which all its permanent files are located, including its executable file, executable file of MetaEditor, standard sounds, etc. In most cases, all the variable files are placed in the same folder at the terminal launch.

Variable files of the terminal include:

all the terminal settings, configuration files;

all the databases (price history);

operation journals of the terminal and Expert Advisors;

all the profiles.

Guest Mode

The distinction of the guest mode is the location of all its variable files separately from permanent ones. This mode is launched when the terminal is installed to a system folder (folder of OS, Program Files) and a user's rights to write into it are limited.

The guest mode is also used in the following situations:

If the UAC (User Activity Control) system is enabled.

If a user is logs in the system using a remote connection (RDP, Remote Desktop Protocol).

In the above described situations all the changeable terminal files are stored in the following directories (depending on the operating system used):

Microsoft Windows XP:

C:\Documents and Settings\username\Application Data\MetaQuotes\Terminal\instance_id\

Microsoft Windows Vista and higher:

C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\instance_id\

Here "C" is the letter of a logical disk, where the operating system is installed, "username" is the account in the operating system, under which the terminal has been installed, and "instance_id" is the unique identifier generated based on the path to a catalog, where the terminal is installed.

A special command — "Open data folder Open data folder" located in the "File" menu is used for quickly accessing these folders.

In the guest mode for each Windows account, the catalog for storing variable files will be different.

To force the terminal to start in the main mode, one should launch it from the command line with the /portable key.

The detailed description of the structure of the client terminal files can be found under the corresponding section.

During the first launch of the terminal you will be automatically offered to open a demonstration account, in order to immediately start working.

 
ianev:


Today one of my agents recorded the following in its log:


PK     2      09:44:03     Tester tester stopped because OnInit reports Tester Agent is not suitable



So apparently a MQL5 program succeeded to start and execute code from its OnInit function. What it considered for unsuitable is not clear.

See MQL5 Reference https://www.mql5.com/en/docs/basis/function/events

To optimize input parameters of an Expert Advisor, it is recommended to use values of the ENUM_INIT_RETCODE enumeration as the return code. These values are used for organizing the course of optimization, including the selection of the most appropriate testing agents. During initialization of an Expert Advisor before the start of testing you can request information about the configuration and resources of an agent (the number of cores, amount of free memory, etc.) using the TerminalInfoInteger() function. Based on the information obtained, you can either allow to use this testing agent, or reject using it during the optimization of this Expert Advisor.

ENUM_INIT_RETCODE

Identifier

Description

INIT_SUCCEEDED

Successful initialization, testing of the Expert Advisor can be continued.

This code means the same as a null value – the Expert Advisor has been successfully initialized in the tester.

INIT_FAILED

Initialization failed; there is no point in continuing testing because of fatal errors. For example, failed to create an indicator that is required for the work of the Expert Advisor.

This return value means the same as a value other than zero - initialization of the Expert Advisor in the tester failed. Testing for the given set of parameters of the Expert Advisor will not be executed, the agent is free to receive a new task.

INIT_PARAMETERS_INCORRECT

This value means the incorrect set of input parameters. The result string containing this return code is highlighted in red in the general optimization table.

 

Upon receiving this value, the strategy tester will reliably not pass this task to other agents for retry.

INIT_AGENT_NOT_SUITABLE

No errors during initialization, but for some reason the agent is not suitable for testing. For example, not enough memory, no OpenCL support, etc.

After the return of this code, the agent will not receive tasks until the end of this optimization.

Documentation on MQL5: Language Basics / Functions / Event Handling Functions
Documentation on MQL5: Language Basics / Functions / Event Handling Functions
  • www.mql5.com
Language Basics / Functions / Event Handling Functions - Documentation on MQL5
 
Rosh:

Have you read built-in terminal Help - https://www.metatrader5.com/en/terminal/help/start_advanced/start

I don't use the MetaTrader terminal for installation of remote agents. For that purpose I use the standalone MetaTester application. This thread is about that application.

I'm aware of that text. What an MQL5 program considers for unsuitable environment is not clear, because it does not inform the MetaTester agent for the exact reason(s) for the unsuitability. There is significant difference between lack of enough memory and lack of OpenCL support for example.

Today I saw that one of my agent was used for 23063 ms. So it seems that the configuration which I described at the beginning is correct. However I still don't see my agents in my mql5.com profile and I don't see there incoming payments.

 

Last night four of my agents were online. Only two of them showed in my profile and only one earned credit (0.00001 credits for the previous night). The PR of these two agents were above 100 so they fulfilled the PR criteria. The earned credit is not enough to cover the expenses for electricity for this night and the previous one.

If only the most powerful computers on the MQL5 Cloud are profitable then:
  1. The MQL5 Cloud project is a waste of time and money for most people (as providers of computational resources)
  2. The message on the front page of the MQL5 Cloud project is misleading, because it suggest that every PC can earn income.

2.

 
ianev:

Last night four of my agents were online. Only two of them showed in my profile and only one earned credit (0.00001 credits for the previous night). The PR of these two agents were above 100 so they fulfilled the PR criteria. The earned credit is not enough to cover the expenses for electricity for this night and the previous one.

If only the most powerful computers on the MQL5 Cloud are profitable then:
  1. The MQL5 Cloud project is a waste of time and money for most people (as providers of computational resources)
  2. The message on the front page of the MQL5 Cloud project is misleading, because it suggest that every PC can earn income.

1.  Probably

2.  Every PC  can   . . .  it doesn't mean every PC will,  if there is no work then agents aren't needed and not every PC will be used. 

 
RaptorUK:

1.  Probably

2.  Every PC  can   . . .  it doesn't mean every PC will,  if there is no work then agents aren't needed and not every PC will be used. 

I don’t see what you want to say with that word play. The MQL5 Cloud project is presented misleadingly, because not enough information is given to the potential participant to make informed decision whether or not it is worthwhile to join the project and because the advertised benefit apparently is not real for some PCs which meet the participation criteria. Some important details about the MQL5 project are not said openly. For example it is not said on the project site:

  1. The fact that some MQL5 programs can choose on what hardware to work and to what extent this can affect the utilization of an agent.
  2. The expected utilization of computational resources. There is a page with statistical data, but it is not clear from it how frequently will be used an agent from the network.
  3. The expected payment for the work of an agent. The payment depends on a value called PR, which is unknown before the joining of an agent to the MQL5 Cloud.

That said. For the last night I got additional 0.000000005 credits (1 credit = 1 USD) from two agents (with PR > 100) online.

Statistics - MQL5 Cloud Network
Statistics - MQL5 Cloud Network
  • cloud.mql5.com
Amount of produced work, agents distribution by countries, RAM, CPU and OS bit count
 
ianev:

I don’t see what you want to say with that word play. 

DYOR.
Reason: