Articles with examples of trading robots developed in MQL5

icon

An Expert Advisor is the 'pinnacle' of programming and the desired goal of every automated trading developer. Read the articles in this section to create your own trading robot. By following the described steps you will learn how to create, debug and test automated trading systems.

The articles not only teach MQL5 programming, but also show how to implement trading ideas and techniques. You will learn how to program a trailing stop, how to apply money management, how to get the indicator values, and much more.

Add a new article
latest | best
preview
Neural networks made easy (Part 6): Experimenting with the neural network learning rate

Neural networks made easy (Part 6): Experimenting with the neural network learning rate

We have previously considered various types of neural networks along with their implementations. In all cases, the neural networks were trained using the gradient decent method, for which we need to choose a learning rate. In this article, I want to show the importance of a correctly selected rate and its impact on the neural network training, using examples.
Optimal approach to the development and analysis of trading systems
Optimal approach to the development and analysis of trading systems

Optimal approach to the development and analysis of trading systems

In this article, I will show the criteria to be used when selecting a system or a signal for investing your funds, as well as describe the optimal approach to the development of trading systems and highlight the importance of this matter in Forex trading.
preview
Timeseries in DoEasy library (part 57): Indicator buffer data object

Timeseries in DoEasy library (part 57): Indicator buffer data object

In the article, develop an object which will contain all data of one buffer for one indicator. Such objects will be necessary for storing serial data of indicator buffers. With their help, it will be possible to sort and compare buffer data of any indicators, as well as other similar data with each other.
preview
Timeseries in DoEasy library (part 56): Custom indicator object, get data from indicator objects in the collection

Timeseries in DoEasy library (part 56): Custom indicator object, get data from indicator objects in the collection

The article considers creation of the custom indicator object for the use in EAs. Let’s slightly improve library classes and add methods to get data from indicator objects in EAs.
preview
Neural networks made easy (Part 5): Multithreaded calculations in OpenCL

Neural networks made easy (Part 5): Multithreaded calculations in OpenCL

We have earlier discussed some types of neural network implementations. In the considered networks, the same operations are repeated for each neuron. A logical further step is to utilize multithreaded computing capabilities provided by modern technology in an effort to speed up the neural network learning process. One of the possible implementations is described in this article.
preview
Neural networks made easy (Part 4): Recurrent networks

Neural networks made easy (Part 4): Recurrent networks

We continue studying the world of neural networks. In this article, we will consider another type of neural networks, recurrent networks. This type is proposed for use with time series, which are represented in the MetaTrader 5 trading platform by price charts.
preview
Timeseries in DoEasy library (part 54): Descendant classes of abstract base indicator

Timeseries in DoEasy library (part 54): Descendant classes of abstract base indicator

The article considers creation of classes of descendant objects of base abstract indicator. Such objects will provide access to features of creating indicator EAs, collecting and getting data value statistics of various indicators and prices. Also, create indicator object collection from which getting access to properties and data of each indicator created in the program will be possible.
preview
Continuous walk-forward optimization (Part 8): Program improvements and fixes

Continuous walk-forward optimization (Part 8): Program improvements and fixes

The program has been modified based on comments and requests from users and readers of this article series. This article contains a new version of the auto optimizer. This version implements requested features and provides other improvements, which I found when working with the program.
preview
CatBoost machine learning algorithm from Yandex with no Python or R knowledge required

CatBoost machine learning algorithm from Yandex with no Python or R knowledge required

The article provides the code and the description of the main stages of the machine learning process using a specific example. To obtain the model, you do not need Python or R knowledge. Furthermore, basic MQL5 knowledge is enough — this is exactly my level. Therefore, I hope that the article will serve as a good tutorial for a broad audience, assisting those interested in evaluating machine learning capabilities and in implementing them in their programs.
preview
Websockets for MetaTrader 5

Websockets for MetaTrader 5

Before the introduction of the network functionality provided with the updated MQL5 API, MetaTrader programs have been limited in their ability to connect and interface with websocket based services. But of course this has all changed, in this article we will explore the implementation of a websocket library in pure MQL5. A brief description of the websocket protocol will be given along with a step by step guide on how to use the resulting library.
A system of voice notifications for trade events and signals
A system of voice notifications for trade events and signals

A system of voice notifications for trade events and signals

Nowadays, voice assistants play a prominent role in human life, as we often use navigators, voice search and translators. In this article, I will try to develop a simple and user friendly system of voice notifications for various trade events, market states or signals generated by trading signals.
Native Twitter Client for MT4 and MT5 without DLL
Native Twitter Client for MT4 and MT5 without DLL

Native Twitter Client for MT4 and MT5 without DLL

Ever wanted to access tweets and/or post your trade signals on Twitter ? Search no more, these on-going article series will show you how to do it without using any DLL. Enjoy the journey of implementing Twitter API using MQL. In this first part, we will follow the glory path of authentication and authorization in accessing Twitter API.
Developing a cross-platform grid EA: testing a multi-currency EA
Developing a cross-platform grid EA: testing a multi-currency EA

Developing a cross-platform grid EA: testing a multi-currency EA

Markets dropped down by more that 30% within one month. It seems to be the best time for testing grid- and martingale-based Expert Advisors. This article is an unplanned continuation of the series "Creating a Cross-Platform Grid EA". The current market provides an opportunity to arrange a stress rest for the grid EA. So, let's use this opportunity and test our Expert Advisor.
Projects assist in creating profitable trading robots! Or at least, so it seems
Projects assist in creating profitable trading robots! Or at least, so it seems

Projects assist in creating profitable trading robots! Or at least, so it seems

A big program starts with a small file, which then grows in size as you keep adding more functions and objects. Most robot developers utilize include files to handle this problem. However, there is a better solution: start developing any trading application in a project. There are so many reasons to do so.
preview
Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer)

Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer)

The main purpose of the article is to describe the mechanism of working with our application and its capabilities. Thus the article can be treated as an instruction on how to use the application. It covers all possible pitfalls and specifics of the application usage.
preview
How to create 3D graphics using DirectX in MetaTrader 5

How to create 3D graphics using DirectX in MetaTrader 5

3D graphics provide excellent means for analyzing huge amounts of data as they enable the visualization of hidden patterns. These tasks can be solved directly in MQL5, while DireсtX functions allow creating three-dimensional object. Thus, it is even possible to create programs of any complexity, even 3D games for MetaTrader 5. Start learning 3D graphics by drawing simple three-dimensional shapes.
MQL5 Cookbook: Trading strategy stress testing using custom symbols
MQL5 Cookbook: Trading strategy stress testing using custom symbols

MQL5 Cookbook: Trading strategy stress testing using custom symbols

The article considers an approach to stress testing of a trading strategy using custom symbols. A custom symbol class is created for this purpose. This class is used to receive tick data from third-party sources, as well as to change symbol properties. Based on the results of the work done, we will consider several options for changing trading conditions, under which a trading strategy is being tested.
Optimization management (Part II): Creating key objects and add-on logic
Optimization management (Part II): Creating key objects and add-on logic

Optimization management (Part II): Creating key objects and add-on logic

This article is a continuation of the previous publication related to the creation of a graphical interface for optimization management. The article considers the logic of the add-on. A wrapper for the MetaTrader 5 terminal will be created: it will enable the running of the add-on as a managed process via C#. In addition, operation with configuration files and setup files is considered in this article. The application logic is divided into two parts: the first one describes the methods called after pressing a particular key, while the second part covers optimization launch and management.
Optimization management (Part I): Creating a GUI
Optimization management (Part I): Creating a GUI

Optimization management (Part I): Creating a GUI

This article describes the process of creating an extension for the MetaTrader terminal. The solution discussed helps to automate the optimization process by running optimizations in other terminals. A few more articles will be written concerning this topic. The extension has been developed using the C# language and design patterns, which additionally demonstrates the ability to expand the terminal capabilities by developing custom modules, as well as the ability to create custom graphical user interfaces using the functionality of a preferred programming language.
Price velocity measurement methods
Price velocity measurement methods

Price velocity measurement methods

There are multiple different approaches to market research and analysis. The main ones are technical and fundamental. In technical analysis, traders collect, process and analyze numerical data and parameters related to the market, including prices, volumes, etc. In fundamental analysis, traders analyze events and news affecting the markets directly or indirectly. The article deals with price velocity measurement methods and studies trading strategies based on that methods.
Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#
Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#

Developing graphical interfaces for Expert Advisors and indicators based on .Net Framework and C#

The article presents a simple and fast method of creating graphical windows using Visual Studio with subsequent integration into the Expert Advisor's MQL code. The article is meant for non-specialist audiences and does not require any knowledge of C# and .Net technology.
Applying Monte Carlo method in reinforcement learning
Applying Monte Carlo method in reinforcement learning

Applying Monte Carlo method in reinforcement learning

In the article, we will apply Reinforcement learning to develop self-learning Expert Advisors. In the previous article, we considered the Random Decision Forest algorithm and wrote a simple self-learning EA based on Reinforcement learning. The main advantages of such an approach (trading algorithm development simplicity and high "training" speed) were outlined. Reinforcement learning (RL) is easily incorporated into any trading EA and speeds up its optimization.
Reversal patterns: Testing the Head and Shoulders pattern
Reversal patterns: Testing the Head and Shoulders pattern

Reversal patterns: Testing the Head and Shoulders pattern

This article is a follow-up to the previous one called "Reversal patterns: Testing the Double top/bottom pattern". Now we will have a look at another well-known reversal pattern called Head and Shoulders, compare the trading efficiency of the two patterns and make an attempt to combine them into a single trading system.
Reversal patterns: Testing the Double top/bottom pattern
Reversal patterns: Testing the Double top/bottom pattern

Reversal patterns: Testing the Double top/bottom pattern

Traders often look for trend reversal points since the price has the greatest potential for movement at the very beginning of a newly formed trend. Consequently, various reversal patterns are considered in the technical analysis. The Double top/bottom is one of the most well-known and frequently used ones. The article proposes the method of the pattern programmatic detection. It also tests the pattern's profitability on history data.
Using limit orders instead of Take Profit without changing the EA's original code
Using limit orders instead of Take Profit without changing the EA's original code

Using limit orders instead of Take Profit without changing the EA's original code

Using limit orders instead of conventional take profits has long been a topic of discussions on the forum. What is the advantage of this approach and how can it be implemented in your trading? In this article, I want to offer you my vision of this topic.
Movement continuation model - searching on the chart and execution statistics
Movement continuation model - searching on the chart and execution statistics

Movement continuation model - searching on the chart and execution statistics

This article provides programmatic definition of one of the movement continuation models. The main idea is defining two waves — the main and the correction one. For extreme points, I apply fractals as well as "potential" fractals - extreme points that have not yet formed as fractals.
EA remote control methods
EA remote control methods

EA remote control methods

The main advantage of trading robots lies in the ability to work 24 hours a day on a remote VPS server. But sometimes it is necessary to intervene in their work, while there may be no direct access to the server. Is it possible to manage EAs remotely? The article proposes one of the options for controlling EAs via external commands.
Using indicators for optimizing Expert Advisors in real time
Using indicators for optimizing Expert Advisors in real time

Using indicators for optimizing Expert Advisors in real time

Efficiency of any trading robot depends on the correct selection of its parameters (optimization). However, parameters that are considered optimal for one time interval may not retain their effectiveness in another period of trading history. Besides, EAs showing profit during tests turn out to be loss-making in real time. The issue of continuous optimization comes to the fore here. When facing plenty of routine work, humans always look for ways to automate it. In this article, I propose a non-standard approach to solving this issue.
Elder-Ray (Bulls Power and Bears Power)
Elder-Ray (Bulls Power and Bears Power)

Elder-Ray (Bulls Power and Bears Power)

The article dwells on Elder-Ray trading system based on Bulls Power, Bears Power and Moving Average indicators (EMA — exponential averaging). This system was described by Alexander Elder in his book "Trading for a Living".
Combining trend and flat strategies
Combining trend and flat strategies

Combining trend and flat strategies

There are numerous trading strategies out there. Some of them look for a trend, while others define ranges of price fluctuations to trade within them. Is it possible to combine these two approaches to increase profitability?
Expert Advisor featuring GUI: Adding functionality (part II)
Expert Advisor featuring GUI: Adding functionality (part II)

Expert Advisor featuring GUI: Adding functionality (part II)

This is the second part of the article showing the development of a multi-symbol signal Expert Advisor for manual trading. We have already created the graphical interface. It is now time to connect it with the program's functionality.
Integrating MQL-based Expert Advisors and databases (SQL Server, .NET and C#)
Integrating MQL-based Expert Advisors and databases (SQL Server, .NET and C#)

Integrating MQL-based Expert Advisors and databases (SQL Server, .NET and C#)

The article describes how to add the ability to work with Microsoft SQL Server database server to MQL5-based Expert Advisors. Import of functions from a DLL is used. The DLL is created using the Microsoft .NET platform and the C# language. The methods used in the article are also suitable for experts written in MQL4, with minor adjustments.
Visualizing optimization results using a selected criterion
Visualizing optimization results using a selected criterion

Visualizing optimization results using a selected criterion

In the article, we continue to develop the MQL application for working with optimization results. This time, we will show how to form the table of the best results after optimizing the parameters by specifying another criterion via the graphical interface.
Implementing indicator calculations into an Expert Advisor code
Implementing indicator calculations into an Expert Advisor code

Implementing indicator calculations into an Expert Advisor code

The reasons for moving an indicator code to an Expert Advisor may vary. How to assess the pros and cons of this approach? The article describes implementing an indicator code into an EA. Several experiments are conducted to assess the speed of the EA's operation.
Deep Neural Networks (Part VI). Ensemble of neural network classifiers: bagging
Deep Neural Networks (Part VI). Ensemble of neural network classifiers: bagging

Deep Neural Networks (Part VI). Ensemble of neural network classifiers: bagging

The article discusses the methods for building and training ensembles of neural networks with bagging structure. It also determines the peculiarities of hyperparameter optimization for individual neural network classifiers that make up the ensemble. The quality of the optimized neural network obtained in the previous article of the series is compared with the quality of the created ensemble of neural networks. Possibilities of further improving the quality of the ensemble's classification are considered.
Expert Advisor featuring GUI: Creating the panel (part I)
Expert Advisor featuring GUI: Creating the panel (part I)

Expert Advisor featuring GUI: Creating the panel (part I)

Despite the fact that many traders still prefer manual trading, it is hardly possible to completely avoid the automation of routine operations. The article shows an example of developing a multi-symbol signal Expert Advisor for manual trading.
Random Decision Forest in Reinforcement learning
Random Decision Forest in Reinforcement learning

Random Decision Forest in Reinforcement learning

Random Forest (RF) with the use of bagging is one of the most powerful machine learning methods, which is slightly inferior to gradient boosting. This article attempts to develop a self-learning trading system that makes decisions based on the experience gained from interaction with the market.
Developing multi-module Expert Advisors
Developing multi-module Expert Advisors

Developing multi-module Expert Advisors

MQL programming language allows implementing the concept of modular development of trading strategies. The article shows an example of developing a multi-module Expert Advisor consisting of separately compiled file modules.
Multi-symbol balance graph in MetaTrader 5
Multi-symbol balance graph in MetaTrader 5

Multi-symbol balance graph in MetaTrader 5

The article provides an example of an MQL application with its graphical interface featuring multi-symbol balance and deposit drawdown graphs based on the last test results.
Money Management by Vince. Implementation as a module for MQL5 Wizard
Money Management by Vince. Implementation as a module for MQL5 Wizard

Money Management by Vince. Implementation as a module for MQL5 Wizard

The article is based on 'The Mathematics of Money Management' by Ralph Vince. It provides the description of empirical and parametric methods used for finding the optimal size of a trading lot. Also the article features implementation of trading modules for the MQL5 Wizard based on these methods.