Previous  Next

Expert Advisors and Custom Indicators

Two broad categories can be singled out among automated trading applications: trading robots and indicators. Applications of the first type are designed for performing trading operations, and the second type programs are used for analyzing prices and identifying patterns in price changes. Indicators can be used directly in trading robots forming a complete automated trading system.

How to Run a Trading Robot or an Indicator

To start an Expert Advisor, attach it to a chart. The easiest way is to double-click on an Expert Advisor in the Navigator window or drag'n'drop it to a chart.

Starting a trading robot on a chart

This will bring up the Expert Advisor Properties window. Click OK to start the Expert Advisors on the chart. If an Expert Advisor has been successfully started, its name and icon Auto Trading enabled appear in the upper right corner of the chart.

If the icon is Auto Trading disabled, the Expert Advisor is not allowed to perform trading operations. Enable automated trading in the Expert Advisor settings, as well as in the trading platform options.

  • Only one Expert Advisor can run on one chart. If you start another Expert Advisor on the same chart, the first one is removed.
  • The number of indicators applied on one chart is not limited.

Application Setup before Start

A window of application properties opens before it is started on a chart.

Common

The "Common" tab contains information about the application: name, version, copyright, the software developing company name (two last parameters can be represented as links to the corresponding web page) and description.

If a license is required for an Expert Advisor (for example, it is purchased or downloaded from the Market), the appropriate license details (expiration date, demo) are displayed here.

Individual parameters of the Expert Advisor start are set up at the bottom of the window:

Common parameters for all Expert Advisors are specified in the trading platform settings.

Input Parameters of Trading Robots and Indicators

An application can have input parameters. They allow you to control the behavior of the application making its use more flexible. An application may have no input parameters if a developer has not provided them.

Input parameters

How to modify application parameters

To modify a parameter, double-click on it and enter a new value.

How to use parameter presets

You can use the "Save" button to save the current set of parameters and the "Load" button to load a previously saved set. Sets of input parameters are stored in the /Presets folder of the trading platform.

How to restore default settings

To restore the default settings, click "Reset".

Already attached Expert Advisors can be individually configured. However, the Expert Advisor properties window cannot be opened during the current execution. This can only be done in periods between the Start() function calls. In this case an Expert Advisor will not be started until its parameters window is closed. If input parameters of an Expert Advisors have been changed, the EA is re-initialized with new input parameters after the "OK" button is pressed.

Programs Using External Functions (DLL)

The "Dependencies" tab appears if the Expert Advisor uses the import of functions from other EX5 or DLL files. Use of external DLLs can extend the functionality of the program. However, it is potentially dangerous. These functions should be allowed only for trusted applications.

Dependencies

Files used by the Expert Advisor are displayed as a tree-like list. The green icons indicate calls of functions from MQL5 programs, and the red icons indicate calls of functions within DLLs.

An option for enabling/disabling DLLs is available at the top of the tab:

Do not enable the "Allow use DLL imports" option if you are not sure that launching the application is safe. Applications obtained from unknown sources may cause damage through the use of third-party DLLs.

How to Control Expert Advisor Trading

The possibility of automated trading can be controlled at the trading platform level or separately for every trading robot.

Button "Auto Trading Enabled AutoTrading" on the toolbar (and a similar option in Options — Expert Advisors) enables/disables automated trading in the platform. If you turn it off, automated trading is disabled for all Expert Advisors even if you enable automated trading individually in the Expert Advisors settings. If you enable it, the Expert Advisors is allowed to trade, unless automated trading is individually disabled in the Expert Advisor parameters.

Control over Expert Advisor trading

Automated trading permissions can be conveniently managed for individual Expert Advisors from the Navigator window, rather than in their parameters. In the Navigator window, the list of all running Expert Advisors is displayed for a connected account. In addition to the Expert Advisor name, a chart on which the EA is running is specified in the list. An icon indicates whether the EA is allowed to trade.

Expert Advisors running on the current account

The context menu contains commands for enabling or disabling automated trading for any of the Expert Advisors, as well as for viewing its properties or removing it from the chart.

Which Platform Settings Affect Automated Trading?

Settings affecting automated trading are available on the Expert Advisors tab of the platform options.

Expert Advisors

The following settings are available:

Quick Access to Frequently Used Programs

For quick access to frequently used programs, use "Favorites" and hotkeys.

Select a trading robot, an indicator or a script and add it to your Favorites using the context menu. All of your favorite programs are displayed on a separate tab of the Navigator and can be easily accessed.

For a quick start on a chart, any program can be assigned a key shortcut. This can be done through the context menu of the Navigator window.

Adding programs to Favorites and assigning hotkeys

In the above example, keys "Alt+1" are set for a script. Once they are pressed, the script is instantly launched on the current open chart.

Services

The trading platform features a special type of programs called Services. Such apps enable the use of custom price feeds for the terminal and to implement price delivery from external systems in real time, just like it is implemented on brokers' trade servers. Services can also be used to perform other service tasks in the background.

Unlike Expert Advisors, indicators and scripts, services are not linked to a specific chart. Such applications run in the background and are launched automatically when the terminal is started (if they were previously launched).

Use the Navigator to manage services:

Managing Services from the Navigator

To run multiple copies of an Expert Advisor or indicator with different parameters, you should launch them on different charts. In this case different program instances are created, which then operate independently. Services are not linked to charts, therefore a special mechanism has been implemented for the creation of service instances. Select a service from the Navigator and click "Add service" in its context menu. This will open a standard MQL5 program dialog, in which you can enable/disable trading and access to signal settings, as well as set various parameters.

Creating an instance, launching and stopping the service

A service instance can be launched and stopped using the appropriate instance menu. To manage all instances, use the service menu.

Python scripts

The are a lot of machine learning, process automation, as well as data analysis and visualization libraries for the Python language. The advanced language possibilities can now be applied in the platform through the Python integration module.

Python scripts can be launched directly on platform charts, similarly to regular MQL5 programs. These scripts are marked with special icons in the Navigator.

Running a Python script in the trading platform

Script messages are displayed under the "Toolbox \ Experts" section.

Python scripts can be launched on the same chart in parallel with other MQL5 scripts and Expert Advisors. To stop a script with a looped execution, remove it from the chart.

To enable additional account protection when using third-party Python libraries, you may use the "Disable automated trading via external Python API" option in terminal settings.

For account protection purposes, automated trading for Python scripts needs to be explicitly allowed

Python scripts can only perform trading operations when this option is disabled.