MetaEditor Help

Creating a ready-made Expert Advisor

Creating a ready-made Expert Advisor

MQL4/MQL5 Wizard allows creating fully operational EAs based on the standard library supplied together with the trading platform. To do this, select "Expert Advisor (generate)" on the first page of MQL4/MQL5 Wizard.

General parameters

General parameters

Fill in the following fields:

  • Name – EA name. The same name is assigned to an EA file. Here you can also change the path to a destination file. For example, create it in the new \Experts subfolders.
  • Author – author name.
  • Link – developer's email address or website.

A set of mandatory parameters created by default is described below:

  • Symbol – specify a symbol the EA is to work on in the Value field. If "current", the EA works on any symbol. A chart symbol the EA is attached to is to be used as a working symbol.
  • TimeFrame – specify a period the EA is to work on in the Value field. If "current", the EA works on any chart period.

The Expert Advisor does not run on charts with a symbol or a period other than the ones specified in its settings. In case of an incorrect symbol or period, the appropriate message is displayed in the platform log.

Signals

Signal modules are selected at this stage. An EA makes trading decisions based on data received from them. 64 modules are available in total. You can add any combination of modules, as well as a few similar modules with different settings, to the EA.

The mechanism of making trade decisions is described in the MQL5 Reference.

To add or change the module settings, click Add or Modify.

Signals

Specify signal module parameters:

Each signal module has a certain set of built-in parameters:

  • Name – parameter name. For example, PeriodMA is a period of applied moving average.
  • Type – parameter variable type. For example, int means integer.
  • Value – default parameter value.
  • If the parameter is marked with Active icon, it is available as an EA input variable. Such parameters can be changed during the EA operation and used when optimizing in the strategy tester. Double-click on the parameter to make it fixed (unavailable for modification when the Expert Advisor is running). Its icon turns gray – Inactive.
  • Each module has its own Weight parameter. It defines the module signal weight considered when making the final decision on a trading operation. The mechanism of making trade decisions is described in MQL5 Reference.

Trailing

At this stage, select the type of moving stop loss and take profit levels.

Trailing

Select a trailing type in the Name field. Source code files of the function data are located in the folder [platform data directory]\MQL5\Include\Expert\Trailing\. Each type of trailing has its own set of parameters.

  • Name – parameter name.
  • Type – parameter variable type.
  • Value – default parameter value.

If the parameter is marked with Active icon, it is available as an EA input variable. Such parameters can be changed during the EA operation and used when optimizing in the strategy tester. Double-click on the parameter, to make it fixed (unavailable for modification when the Expert Advisor is running). Its icon turns gray – Inactive.

Money management

At this stage, you should select a money management type for your EA.

Money management

Set a money management type in the Name field. Source code files of the function data are located in the folder [platform data directory]\MQL5\Include\Expert\Money\. Each type of money management has its own set of parameters.

  • Name – parameter name.
  • Type – parameter variable type.
  • Value – default parameter value.

If the parameter is marked with Active icon, it is available as an EA input variable. Such parameters can be changed during the EA operation and used when optimizing in the strategy tester. Double-click on the parameter, to make it fixed (unavailable for modification when the Expert Advisor is running). Its icon turns gray – Inactive.

Click Finish to generate an MQ5 file of the EA. To obtain an executable EA file that can be run in the trading platform, compile the obtained MQ5 file. To do this, click Compile Compile or F7.

Special classes from the Standard library are used as signal, trailing and money management modules. In addition, you can write your own classes (as well as create them based on the existing ones). Place them in the following directories to make them available in MQL5 Wizard:

  • Signal modules: [platform directory]\MQL5\Include\Expert\Signal
  • Trailing modules: [platform directory]\MQL5\Include\Expert\Trailing
  • Money management modules: [platform directory]\MQL5\Include\Expert\Money

Find out more about creating your own modules in the article "MQL5 Wizard: How to create a module of trading signals".