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
Graphical Interfaces VII: the Tables Controls (Chapter 1)
Graphical Interfaces VII: the Tables Controls (Chapter 1)

Graphical Interfaces VII: the Tables Controls (Chapter 1)

The seventh part of the series on MetaTrader graphical interfaces deals with three table types: text label, edit box and rendered one. Another important and frequently used controls are tabs allowing you to show/hide groups of other controls and develop space effective interfaces in your MQL applications.
preview
Neural networks made easy (Part 12): Dropout

Neural networks made easy (Part 12): Dropout

As the next step in studying neural networks, I suggest considering the methods of increasing convergence during neural network training. There are several such methods. In this article we will consider one of them entitled Dropout.
MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters
MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters

MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters

In this article, we will create a pattern that uses a single set of parameters for optimization of a trading system, while allowing for unlimited number of parameters. The list of symbols will be created in a standard text file (*.txt). Input parameters for each symbol will also be stored in files. This way we will be able to circumvent the restriction of the terminal on the number of input parameters of an Expert Advisor.
Graphical Interfaces II: The Main Menu Element (Chapter 4)
Graphical Interfaces II: The Main Menu Element (Chapter 4)

Graphical Interfaces II: The Main Menu Element (Chapter 4)

This is the final chapter of the second part of the series about graphical interfaces. Here, we are going to consider the creation of the main menu. The development of this control and setting up handlers of the library classes for correct reaction to the user's actions will be demonstrated here. We will also discuss how to attach context menus to the items of the main menu. Adding to that, we will mention blocking currently inactive elements.
Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor
Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor

Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor

Just over a year ago joo, in his article "Genetic Algorithms - It's Easy!", gave us a tool for implementation of the genetic algorithm in MQL5. Now utilizing the tool we will create an Expert Advisor that will genetically optimize its own parameters upon certain boundary conditions...
preview
Neural networks made easy (Part 8): Attention mechanisms

Neural networks made easy (Part 8): Attention mechanisms

In previous articles, we have already tested various options for organizing neural networks. We also considered convolutional networks borrowed from image processing algorithms. In this article, I suggest considering Attention Mechanisms, the appearance of which gave impetus to the development of language models.
The market and the physics of its global patterns
The market and the physics of its global patterns

The market and the physics of its global patterns

In this article, I will try to test the assumption that any system with even a small understanding of the market can operate on a global scale. I will not invent any theories or patterns, but I will only use known facts, gradually translating these facts into the language of mathematical analysis.
Graphical Interfaces V: The Vertical and Horizontal Scrollbar (Chapter 1)
Graphical Interfaces V: The Vertical and Horizontal Scrollbar (Chapter 1)

Graphical Interfaces V: The Vertical and Horizontal Scrollbar (Chapter 1)

We are still discussing the development of the library for creating graphical interfaces in the MetaTrader environment. In the first article of the fifth part of the series, we will write classes for creating vertical and horizontal scrollbars.
Graphical Interfaces IX: The Progress Bar and Line Chart Controls (Chapter 2)
Graphical Interfaces IX: The Progress Bar and Line Chart Controls (Chapter 2)

Graphical Interfaces IX: The Progress Bar and Line Chart Controls (Chapter 2)

The second chapter of the part nine is dedicated to the progress bar and line chart controls. As always, there will be detailed examples provided to reveal how these controls can be used in custom MQL applications.
preview
Can Heiken-Ashi Combined With Moving Averages Provide Good Signals Together?

Can Heiken-Ashi Combined With Moving Averages Provide Good Signals Together?

Combinations of strategies may offer better opportunities. We can combine indicators or patterns together, or even better, indicators with patterns, so that we get an extra confirmation factor. Moving averages help us confirm and ride the trend. They are the most known technical indicators and this is because of their simplicity and their proven track record of adding value to analyses.
Graphical Interfaces IV: Informational Interface Elements (Chapter 1)
Graphical Interfaces IV: Informational Interface Elements (Chapter 1)

Graphical Interfaces IV: Informational Interface Elements (Chapter 1)

At the current stage of development, the library for creating graphical interfaces contains a form and several controls that can be attached to it. It was mentioned before that one of the future articles would be dedicated to the multi-window mode. Now, we have everything ready for that and we will deal with it in the following chapter. In this chapter, we will write classes for creating the status bar and tooltip informational interface elements.
preview
CCI indicator. Upgrade and new features

CCI indicator. Upgrade and new features

In this article, I will consider the possibility of upgrading the CCI indicator. Besides, I will present a modification of the indicator.
MQL5 Cookbook: ОСО Orders
MQL5 Cookbook: ОСО Orders

MQL5 Cookbook: ОСО Orders

Any trader's trading activity involves various mechanisms and interrelationships including relations among orders. This article suggests a solution of OCO orders processing. Standard library classes are extensively involved, as well as new data types are created herein.
Graphical Interfaces VII: The Tabs Control (Chapter 2)
Graphical Interfaces VII: The Tabs Control (Chapter 2)

Graphical Interfaces VII: The Tabs Control (Chapter 2)

The first chapter of seventh part introduced three classes of controls for creating tables: text label table (CLabelsTable), edit box table (CTable) and rendered table (CCanvasTable). In this article (chapter two) we are going to consider the Tabs control.
Connecting NeuroSolutions Neuronets
Connecting NeuroSolutions Neuronets

Connecting NeuroSolutions Neuronets

In addition to creation of neuronets, the NeuroSolutions software suite allows exporting them as DLLs. This article describes the process of creating a neuronet, generating a DLL and connecting it to an Expert Advisor for trading in MetaTrader 5.
Self-organizing feature maps (Kohonen maps) - revisiting the subject
Self-organizing feature maps (Kohonen maps) - revisiting the subject

Self-organizing feature maps (Kohonen maps) - revisiting the subject

This article describes techniques of operating with Kohonen maps. The subject will be of interest to both market researchers with basic level of programing in MQL4 and MQL5 and experienced programmers that face difficulties with connecting Kohonen maps to their projects.
MQL5 Cookbook: Position Properties on the Custom Info Panel
MQL5 Cookbook: Position Properties on the Custom Info Panel

MQL5 Cookbook: Position Properties on the Custom Info Panel

This time we will create a simple Expert Advisor that will get position properties on the current symbol and display them on the custom info panel during manual trading. The info panel will be created using graphical objects and displayed information will be refreshed at every tick. This is going to be much more convenient than all the time having to manually run the script described in the previous article of the series called "MQL5 Cookbook: Getting Position Properties".
MQL5 Wizard: How to Create a Module of Trailing of Open Positions
MQL5 Wizard: How to Create a Module of Trailing of Open Positions

MQL5 Wizard: How to Create a Module of Trailing of Open Positions

The generator of trade strategies MQL5 Wizard greatly simplifies the testing of trading ideas. The article discusses how to write and connect to the generator of trade strategies MQL5 Wizard your own class of managing open positions by moving the Stop Loss level to a lossless zone when the price goes in the position direction, allowing to protect your profit decrease drawdowns when trading. It also tells about the structure and format of the description of the created class for the MQL5 Wizard.
Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)
Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)

Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)

In this article we will create the separation line element. It will be possible to use it not only as an independent interface element but also as a part of many other elements. After that, we will have everything required for the development of the context menu class, which will be also considered in this article in detail. Added to that, we will introduce all necessary additions to the class, which is the base for storing pointers to all the elements of the graphical interface of the application.
Graphical Interfaces I: Testing Library in Programs of Different Types and in the MetaTrader 4 Terminal (Chapter 5)
Graphical Interfaces I: Testing Library in Programs of Different Types and in the MetaTrader 4 Terminal (Chapter 5)

Graphical Interfaces I: Testing Library in Programs of Different Types and in the MetaTrader 4 Terminal (Chapter 5)

In the previous chapter of the first part of the series about graphical interfaces, the form class was enriched by methods which allowed managing the form by pressing its controls. In this article, we will test our work in different types of MQL program such as indicators and scripts. As the library was designed to be cross-platform so it could be used in all MetaTrader platforms, we will also test it in MetaTrader 4.
preview
Developing a trading Expert Advisor from scratch (Part 19): New order system (II)

Developing a trading Expert Advisor from scratch (Part 19): New order system (II)

In this article, we will develop a graphical order system of the "look what happens" type. Please note that we are not starting from scratch this time, but we will modify the existing system by adding more objects and events on the chart of the asset we are trading.
Graphical Interfaces X: Sorting, rebuilding the table and controls in the cells (build 11)
Graphical Interfaces X: Sorting, rebuilding the table and controls in the cells (build 11)

Graphical Interfaces X: Sorting, rebuilding the table and controls in the cells (build 11)

We continue to add new features to the rendered table: data sorting, managing the number of columns and rows, setting the table cell types to place controls into them.
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.
Graphical Interfaces X: Word wrapping algorithm in the Multiline Text box (build 12)
Graphical Interfaces X: Word wrapping algorithm in the Multiline Text box (build 12)

Graphical Interfaces X: Word wrapping algorithm in the Multiline Text box (build 12)

We continue to develop the Multiline Text box control. This time our task is to implement an automatic word wrapping in case a text box width overflow occurs, or a reverse word wrapping of the text to the previous line if the opportunity arises.
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.
preview
Making charts more interesting: Adding a background

Making charts more interesting: Adding a background

Many workstations contain some representative image which shows something about the user. These images make the working environment more beautiful and exciting. Let's see how to make the charts more interesting by adding a background.
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.
MQL5 Cookbook: Analyzing Position Properties in the MetaTrader 5 Strategy Tester
MQL5 Cookbook: Analyzing Position Properties in the MetaTrader 5 Strategy Tester

MQL5 Cookbook: Analyzing Position Properties in the MetaTrader 5 Strategy Tester

We will present a modified version of the Expert Advisor from the previous article "MQL5 Cookbook: Position Properties on the Custom Info Panel". Some of the issues we will address include getting data from bars, checking for new bar events on the current symbol, including a trade class of the Standard Library to a file, creating a function to search for trading signals and a function for executing trading operations, as well as determining trade events in the OnTrade() function.
preview
Understanding order placement in MQL5

Understanding order placement in MQL5

When creating any trading system, there is a task we need to deal with effectively. This task is order placement or to let the created trading system deal with orders automatically because it is crucial in any trading system. So, you will find in this article most of the topics that you need to understand about this task to create your trading system in terms of order placement effectively.
Graphical Interfaces IX: The Color Picker Control (Chapter 1)
Graphical Interfaces IX: The Color Picker Control (Chapter 1)

Graphical Interfaces IX: The Color Picker Control (Chapter 1)

With this article we begin chapter nine of series of articles dedicated to creating graphical interfaces in MetaTrader trading terminals. It consists of two chapters where new elements of controls and interface, such as color picker, color button, progress bar and line chart are presented.
Raise Your Linear Trading Systems to the Power
Raise Your Linear Trading Systems to the Power

Raise Your Linear Trading Systems to the Power

Today's article shows intermediate MQL5 programmers how they can get more profit from their linear trading systems (Fixed Lot) by easily implementing the so-called technique of exponentiation. This is because the resulting equity curve growth is then geometric, or exponential, taking the form of a parabola. Specifically, we will implement a practical MQL5 variant of the Fixed Fractional position sizing developed by Ralph Vince.
preview
Developing a trading Expert Advisor from scratch (Part 21): New order system (IV)

Developing a trading Expert Advisor from scratch (Part 21): New order system (IV)

Finally, the visual system will start working, although it will not yet be completed. Here we will finish making the main changes. There will be quite a few of them, but they are all necessary. Well, the whole work will be quite interesting.
Graphical Interfaces V: The List View Element (Chapter 2)
Graphical Interfaces V: The List View Element (Chapter 2)

Graphical Interfaces V: The List View Element (Chapter 2)

In the previous chapter, we wrote classes for creating vertical and horizontal scrollbars. In this chapter, we will implement them. We will write a class for creating the list view element, a compound part of which will be a vertical scrollbar.
preview
Neural networks made easy (Part 29): Advantage Actor-Critic algorithm

Neural networks made easy (Part 29): Advantage Actor-Critic algorithm

In the previous articles of this series, we have seen two reinforced learning algorithms. Each of them has its own advantages and disadvantages. As often happens in such cases, next comes the idea to combine both methods into an algorithm, using the best of the two. This would compensate for the shortcomings of each of them. One of such methods will be discussed in this article.
Graphical Interfaces VIII: The Calendar Control (Chapter 1)
Graphical Interfaces VIII: The Calendar Control (Chapter 1)

Graphical Interfaces VIII: The Calendar Control (Chapter 1)

In the part VIII of the series of articles dedicated to creating graphical interfaces in MetaTrader, we will consider complex composite controls like calendars, tree view, and file navigator. Due to the large amount of information, there are separate articles written for every subject. The first chapter of this part describes the calendar control and its expanded version — a drop down calendar.
preview
How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 1): Indicator Signals based on ADX in combination with Parabolic SAR

How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 1): Indicator Signals based on ADX in combination with Parabolic SAR

The Multi-Currency Expert Advisor in this article is Expert Advisor or trading robot that can trade (open orders, close orders and manage orders an more) for more than 1 symbol pair only from one symbol chart.
Graphical Interfaces II: Setting Up the Event Handlers of the Library (Chapter 3)
Graphical Interfaces II: Setting Up the Event Handlers of the Library (Chapter 3)

Graphical Interfaces II: Setting Up the Event Handlers of the Library (Chapter 3)

The previous articles contain the implementation of the classes for creating constituent parts of the main menu. Now, it is time to take a close look at the event handlers in the principle base classes and in the classes of the created controls. We will also pay special attention to managing the state of the chart depending on the location of the mouse cursor.
Prices in DoEasy library (part 63): Depth of Market and its abstract request class
Prices in DoEasy library (part 63): Depth of Market and its abstract request class

Prices in DoEasy library (part 63): Depth of Market and its abstract request class

In the article, I will start developing the functionality for working with the Depth of Market. I will also create the class of the Depth of Market abstract order object and its descendants.
Graphical Interfaces XI: Text edit boxes and Combo boxes in table cells (build 15)
Graphical Interfaces XI: Text edit boxes and Combo boxes in table cells (build 15)

Graphical Interfaces XI: Text edit boxes and Combo boxes in table cells (build 15)

In this update of the library, the Table control (the CTable class) will be supplemented with new options. The lineup of controls in the table cells is expanded, this time adding text edit boxes and combo boxes. As an addition, this update also introduces the ability to resize the window of an MQL application during its runtime.
Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals
Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals

Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals

Today we will learn how to link an MetaTrader 5 terminal with Twitter so that you can tweet your EAs' trading signals. We are developing a Social Decision Support System in PHP based on a RESTful web service. This idea comes from a particular conception of automatic trading called computer-assisted trading. We want the cognitive abilities of human traders to filter those trading signals which otherwise would be automatically placed on the market by the Expert Advisors.