MetaEditor Help

Creating Ready-Made Expert Advisors

Creating Ready-Made Expert Advisors

The MQL4/MQL5 Wizard allows creating ready-made Expert Advisors based on the standard library delivered together with the client terminal. To start generating an Expert Advisor, select point "Expert Advisor (generate)" on the first page of MQL4/MQL5 Wizard.

The process of generation of an Expert Advisor consists of several steps.

Common Parameters

General properties

In this dialog fill in the following fields:

  • Name — the name of the Expert Advisor, the same name will be given to the file of the Expert Advisor;
  • Author — the name of the author;
  • Link — the e-mail or website address of the developer.

Below is the list of required parameters created on default:

  • Symbol — in the "Value" field you can specify a symbol the Expert Advisor will work on. If you specify "current", the Expert Advisor will work on any symbol. Thus the symbol of a chart where the Expert Advisor is attached will be used as the work symbol;
  • TimeFrame — in the "Value" field you can specify a period the Expert Advisor will work on. If you specify "current", the Expert Advisor will work on any period.

You will not be able to run the Expert Advisor on a symbol or period that is different from the one specified in its parameters. The corresponding message about using an invalid symbol or period is written to the journal of the client terminal.

Signals

In a generated Expert Advisor, trade decisions are made on the basis of the complex analysis of information obtained from the modules of signals. At this stage you can add any combination of modules of signals (up to 64) to the Expert Advisor. You can add several identical modules that have different settings.

The mechanism of making trade decisions is described in details in the Documentation section of MQL5.community.

Signals

This window displays the list of already selected modules of signals and their settings. To add or modify settings of a module, click "Add" or "Modify" respectively. The window of parameters of the signal module will be opened as soon as you do it.

Parameters of Signal Module

Parameters of Singal Module

In this window you can specify the parameters of the added or modified module of signals:

  • Name — the modified (added) module of signals. The source code files of the modules of symbols are located in the folder /MQL5/Include/Expert/Signal/. If you click on the "?" button, you will go to the detailed description of the module.
  • Symbol — the work symbol, its price data will be used by the module for the analysis.
  • Use current — if this option is enabled, the work symbol chosen for the Expert Advisor will be used as the work symbol of the module.
  • Period — the work period that will be analyzed by the module. If you choose "current", the work period chosen for the Expert Advisor will be used as the work period of the module.

For each module of signals there is a certain set of embedded parameters:

  • Name — name of the parameter;
  • Type — type of the parameter variable;
  • Value — default value of the parameter.
  • There are two modes of parameter creation. You can switch between them by a double left mouse button click on the icon. If a parameter's icon is highlighted Active, it will be available as an input variable of the Expert Advisor. Such parameters can be then used for optimizing an Expert Advisor in the strategy tester. If the icon is grey Inactive, it will be set to a fixed value that can't be changed from the Expert Advisor properties.
  • Each module of signals has the Weight parameter. This parameter is used for adjusting the weight of signals of a module and is considered at making final trade decisions on trade operations. The detailed description of the mechanism of making trade decisions is given in the Documentation section of MQL5.community.

Trailing

On this step you select type of trailing of the Stop Loss level.

Trailing

In the "Name" field select one of trailing types from the drop-down list. Files of source codes of these functions are located in the folder terminal_folder/MQL5/include/expert/trailing/.

For each type of trailing there is a certain set of parameters:

  • Name — name of the parameter;
  • Type — type of the parameter variable;
  • Value — default value of the parameter.

There are two modes of parameter creation. You can switch between them by a double left mouse button click on the icon. If a parameter's icon is highlighted Active, it will be available as an input variable of the Expert Advisor. Such parameters can be then used for optimizing an Expert Advisor in the strategy tester. If the icon is grey Inactive, it will be set to a fixed value that can't be changed from the Expert Advisor properties.

Money Management

On this step you select the type of money management for the Expert Advisor.

Money Management

In the "Name" field select one of types of money management from the drop-down list. Files of source codes of these functions are located in the folder terminal_folder/MQL5/include/expert/money/.

For each type of money management there is a certain set of parameters:

  • Name — name of the parameter;
  • Type — type of the parameter variable;
  • Value — default value of the parameter.

There are two modes of parameter creation. You can switch between them by a double left mouse button click on the icon. If a parameter's icon is highlighted Active, it will be available as an input variable of the Expert Advisor. Such parameters can be then used for optimizing an Expert Advisor in the strategy tester. If the icon is grey Inactive, it will be set to a fixed value that can't be changed from the Expert Advisor properties.

After you press "finish" the MQ5 file of your Expert Advisor will be generated. to start using it you need to compile it first by clicking "Compile Compile" or pressing the F7 key.

The MQL4/MQL5 Wizard uses source codes of appropriate classes of Standard libraries that contain the simple description of all parameters set during work of the MQL4/MQL5 Wizard. In addition to the classes included in the standard delivery of the terminal, you can write your own classes or create derived classes with a required set of functions and then place them in appropriate directories.

Write your own classes in accordance with simple rules and your trade signal, trailing methods or money management modules will be taken by the MQL4/MQL5 Wizard and can be then used for creating robots with a wider set of functions.