MQL5 Programming Articles

icon

Study the MQL5 language for programming trading strategies in numerous published articles mostly written by you - the community members. The articles are grouped into categories to help you quicker find answers to any questions related to programming: Integration, Tester, Trading Strategies, etc.

Follow our new publications and discuss them on the Forum!

Add a new article
latest | best
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria

MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria

We continue the series of articles on MQL5 programming. This time we will see how to get results of each optimization pass right during the Expert Advisor parameter optimization. The implementation will be done so as to ensure that if the conditions specified in the external parameters are met, the corresponding pass values will be written to a file. In addition to test values, we will also save the parameters that brought about such results.
preview
Multibot in MetaTrader: Launching multiple robots from a single chart

Multibot in MetaTrader: Launching multiple robots from a single chart

In this article, I will consider a simple template for creating a universal MetaTrader robot that can be used on multiple charts while being attached to only one chart, without the need to configure each instance of the robot on each individual chart.
Combination scalping: analyzing trades from the past to increase the performance of future trades
Combination scalping: analyzing trades from the past to increase the performance of future trades

Combination scalping: analyzing trades from the past to increase the performance of future trades

The article provides the description of the technology aimed at increasing the effectiveness of any automated trading system. It provides a brief explanation of the idea, as well as its underlying basics, possibilities and disadvantages.
MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence
MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence

MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence

In this article, we will consider the development of a multi-symbol indicator to analyze price divergence in a specified period of time. The core topics have been already discussed in the previous article on the programming of multi-currency indicators "MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5". So this time we will dwell only on those new features and functions that have been changed dramatically. If you are new to the programming of multi-currency indicators, I recommend you to first read the previous article.
preview
Finding seasonal patterns in the forex market using the CatBoost algorithm

Finding seasonal patterns in the forex market using the CatBoost algorithm

The article considers the creation of machine learning models with time filters and discusses the effectiveness of this approach. The human factor can be eliminated now by simply instructing the model to trade at a certain hour of a certain day of the week. Pattern search can be provided by a separate algorithm.
preview
Learn how to design a trading system by Ichimoku

Learn how to design a trading system by Ichimoku

Here is a new article in our series about how to design a trading system b the most popular indicators, we will talk about the Ichimoku indicator in detail and how to design a trading system by this indicator.
Interview with Achmad Hidayat (ATC 2012)
Interview with Achmad Hidayat (ATC 2012)

Interview with Achmad Hidayat (ATC 2012)

Throughout the entire duration of the Automated Trading Championship 2012, we will be providing live coverage of the events - hot reports and interviews every week. This report spotlights Achmad Hidayat (achidayat), the participant from Indonesia. On the first day of the Championship his Expert Advisor secured its position in the third ten, which is a good start. Achmad has sparked our interest with his active participation in the MQL5 Market. He has already published over 20 products thus far.
Cross-Platform Expert Advisor: The CExpertAdvisor and CExpertAdvisors Classes
Cross-Platform Expert Advisor: The CExpertAdvisor and CExpertAdvisors Classes

Cross-Platform Expert Advisor: The CExpertAdvisor and CExpertAdvisors Classes

This article deals primarily with the classes CExpertAdvisor and CExpertAdvisors, which serve as the container for all the other components described in this article-series regarding cross-platform expert advisors.
Testing patterns that arise when trading currency pair baskets. Part I
Testing patterns that arise when trading currency pair baskets. Part I

Testing patterns that arise when trading currency pair baskets. Part I

We begin testing the patterns and trying the methods described in the articles about trading currency pair baskets. Let's see how oversold/overbought level breakthrough patterns are applied in practice.
Fundamentals of Statistics
Fundamentals of Statistics

Fundamentals of Statistics

Every trader works using certain statistical calculations, even if being a supporter of fundamental analysis. This article walks you through the fundamentals of statistics, its basic elements and shows the importance of statistics in decision making.
Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio
Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio

Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio

Some traders execute all their trades automatically, and some mix automatic and manual trades based on the output of several indicators. Being a member of the latter group I needed an interactive tool to asses dynamically risk and reward price levels directly from the chart. This article will present a way to implement an interactive semi-automatic Expert Advisor with predefined equity risk and R/R ratio. The Expert Advisor risk, R/R and lot size parameters can be changed during runtime on the EA panel.
Graphical Interfaces V: The Combobox Control (Chapter 3)
Graphical Interfaces V: The Combobox Control (Chapter 3)

Graphical Interfaces V: The Combobox Control (Chapter 3)

In the first two chapters of the fifth part of the series, we developed classes for creating a scrollbar and a view list. In this chapter, we will speak about creating a class for the combobox control. This is also a compound control containing, among others, elements considered in the previous chapters of the fifth part.
preview
Multilayer perceptron and backpropagation algorithm (Part II): Implementation in Python and integration with MQL5

Multilayer perceptron and backpropagation algorithm (Part II): Implementation in Python and integration with MQL5

There is a Python package available for developing integrations with MQL, which enables a plethora of opportunities such as data exploration, creation and use of machine learning models. The built in Python integration in MQL5 enables the creation of various solutions, from simple linear regression to deep learning models. Let's take a look at how to set up and prepare a development environment and how to use use some of the machine learning libraries.
Neural Networks Cheap and Cheerful - Link NeuroPro with MetaTrader 5
Neural Networks Cheap and Cheerful - Link NeuroPro with MetaTrader 5

Neural Networks Cheap and Cheerful - Link NeuroPro with MetaTrader 5

If specific neural network programs for trading seem expensive and complex or, on the contrary, too simple, try NeuroPro. It is free and contains the optimal set of functionalities for amateurs. This article will tell you how to use it in conjunction with MetaTrader 5.
Tips for Selecting a Trading Signal to Subscribe. Step-By-Step Guide
Tips for Selecting a Trading Signal to Subscribe. Step-By-Step Guide

Tips for Selecting a Trading Signal to Subscribe. Step-By-Step Guide

This step-by-step guide is dedicated to the Signals service, examination of trading signals, a system approach to the search of a required signal which would satisfy criteria of profitability, risk, trading ambitions, working on various types of accounts and financial instruments.
Graphical Interfaces X: Text selection in the Multiline Text box (build 13)
Graphical Interfaces X: Text selection in the Multiline Text box (build 13)

Graphical Interfaces X: Text selection in the Multiline Text box (build 13)

This article will implement the ability to select text using various key combinations and deletion of the selected text, similar to the way it is done in any other text editor. In addition, we will continue to optimize the code and prepare the classes to move on to the final process of the second stage of the library's evolution, where all controls will be rendered as separate images (canvases).
Sorting methods and their visualization using MQL5
Sorting methods and their visualization using MQL5

Sorting methods and their visualization using MQL5

The Graphic.mqh library has been designed to work with graphics in MQL5. The article provides an example of its practical application and explains the idea of sorting. The general concept of sorting is described here since each type of sorting already has at least one separate article, while some of sorting types are objects of detailed studies.
preview
Learn how to design a trading system by Bear's Power

Learn how to design a trading system by Bear's Power

Welcome to a new article in our series about learning how to design a trading system by the most popular technical indicator here is a new article about learning how to design a trading system by Bear's Power technical indicator.
Analyzing charts using DeMark Sequential and Murray-Gann levels
Analyzing charts using DeMark Sequential and Murray-Gann levels

Analyzing charts using DeMark Sequential and Murray-Gann levels

Thomas DeMark Sequential is good at showing balance changes in the price movement. This is especially evident if we combine its signals with a level indicator, for example, Murray levels. The article is intended mostly for beginners and those who still cannot find their "Grail". I will also display some features of building levels that I have not seen on other forums. So, the article will probably be useful for advanced traders as well... Suggestions and reasonable criticism are welcome...
MQL5 Cookbook: Developing a Framework for a Trading System Based on the Triple Screen Strategy
MQL5 Cookbook: Developing a Framework for a Trading System Based on the Triple Screen Strategy

MQL5 Cookbook: Developing a Framework for a Trading System Based on the Triple Screen Strategy

In this article, we will develop a framework for a trading system based on the Triple Screen strategy in MQL5. The Expert Advisor will not be developed from scratch. Instead, we will simply modify the program from the previous article "MQL5 Cookbook: Using Indicators to Set Trading Conditions in Expert Advisors" which already substantially serves our purpose. So the article will also demonstrate how you can easily modify patterns of ready-made programs.
Developing the symbol selection and navigation utility in MQL5 and MQL4
Developing the symbol selection and navigation utility in MQL5 and MQL4

Developing the symbol selection and navigation utility in MQL5 and MQL4

Experienced traders are well aware of the fact that most time-consuming things in trading are not opening and tracking positions but selecting symbols and looking for entry points. In this article, we will develop an EA simplifying the search for entry points on trading instruments provided by your broker.
Graphical Interfaces VI: the Slider and the Dual Slider Controls (Chapter 2)
Graphical Interfaces VI: the Slider and the Dual Slider Controls (Chapter 2)

Graphical Interfaces VI: the Slider and the Dual Slider Controls (Chapter 2)

In the previous article, we have enriched our library with four controls frequently used in graphical interfaces: checkbox, edit, edit with checkbox and check combobox. The second chapter of the sixth part will be dedicated to the slider and the dual slider controls.
The Order of Object Creation and Destruction in MQL5
The Order of Object Creation and Destruction in MQL5

The Order of Object Creation and Destruction in MQL5

Every object, whether it is a custom object, a dynamic array or an array of objects, is created and deleted in MQL5-program in its particular way. Often, some objects are part of other objects, and the order of object deleting at deinitialization becomes especially important. This article provides some examples that cover the mechanisms of working with objects.
Selection and navigation utility in MQL5 and MQL4: Adding auto search for patterns and displaying detected symbols
Selection and navigation utility in MQL5 and MQL4: Adding auto search for patterns and displaying detected symbols

Selection and navigation utility in MQL5 and MQL4: Adding auto search for patterns and displaying detected symbols

In this article, we continue expanding the features of the utility for collecting and navigating through symbols. This time, we will create new tabs displaying only the symbols that satisfy some of the necessary parameters and find out how to easily add custom tabs with the necessary sorting rules.
preview
Design Patterns in software development and MQL5 (Part 4): Behavioral Patterns 2

Design Patterns in software development and MQL5 (Part 4): Behavioral Patterns 2

In this article, we will complete our series about the Design Patterns topic, we mentioned that there are three types of design patterns creational, structural, and behavioral. We will complete the remaining patterns of the behavioral type which can help set the method of interaction between objects in a way that makes our code clean.
Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9)
Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9)

Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9)

The article describes the work with indicators through the universal CUnIndicator class. In addition, new methods of working with pending orders are considered. Please note: from this point on, the structure of the CStrategy project has undergone substantial changes. Now all its files are located in a single directory for the convenience of users.
Using MetaTrader 5 as a Signal Provider for MetaTrader 4
Using MetaTrader 5 as a Signal Provider for MetaTrader 4

Using MetaTrader 5 as a Signal Provider for MetaTrader 4

Analyse and examples of techniques how trading analysis can be performed on MetaTrader 5 platform, but executed by MetaTrader 4. Article will show you how to create simple signal provider in your MetaTrader 5, and connect to it with multiple clients, even running MetaTrader 4. Also you will find out how you can follow participants of Automated Trading Championship in your real MetaTrader 4 account.
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2

MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2

This paper continues checking the new conception to describe the window interface of MQL programs, using the structures of MQL. Automatically creating GUI based on the MQL markup provides additional functionality for caching and dynamically generating the elements and controlling the styles and new schemes for processing the events. Attached is an enhanced version of the standard library of controls.
What is a trend and is the market structure based on trend or flat?
What is a trend and is the market structure based on trend or flat?

What is a trend and is the market structure based on trend or flat?

Traders often talk about trends and flats but very few of them really understand what a trend/flat really is and even fewer are able to clearly explain these concepts. Discussing these basic terms is often beset by a solid set of prejudices and misconceptions. However, if we want to make profit, we need to understand the mathematical and logical meaning of these concepts. In this article, I will take a closer look at the essence of trend and flat, as well as try to define whether the market structure is based on trend, flat or something else. I will also consider the most optimal strategies for making profit on trend and flat markets.
LifeHack for Traders: Indicators of Balance, Drawdown, Load and Ticks during Testing
LifeHack for Traders: Indicators of Balance, Drawdown, Load and Ticks during Testing

LifeHack for Traders: Indicators of Balance, Drawdown, Load and Ticks during Testing

How to make the testing process more visual? The answer is simple: you need to use one or more indicators in the Strategy Tester, including a tick indicator, an indicator of balance and equity, an indicator of drawdown and deposit load. This solution will help you visually track the nature of ticks, balance and equity changes, as well as drawdown and deposit load.
preview
Money management in trading

Money management in trading

We will look at several new ways of building money management systems and define their main features. Today, there are quite a few money management strategies to fit every taste. We will try to consider several ways to manage money based on different mathematical growth models.
Deep Neural Networks (Part II). Working out and selecting predictors
Deep Neural Networks (Part II). Working out and selecting predictors

Deep Neural Networks (Part II). Working out and selecting predictors

The second article of the series about deep neural networks will consider the transformation and choice of predictors during the process of preparing data for training a model.
MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5
MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5

MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5

In this article, we will consider the development of a multi-symbol volatility indicator. The development of multi-symbol indicators may present some difficulties for novice MQL5 developers which this article helps to clarify. The major issues arising in the course of development of a multi-symbol indicator have to do with the synchronization of other symbols' data with respect to the current symbol, the lack of some indicator data and the identification of the beginning of 'true' bars of a given time frame. All of these issues will be closely considered in the article.
Analysis of the Main Characteristics of Time Series
Analysis of the Main Characteristics of Time Series

Analysis of the Main Characteristics of Time Series

This article introduces a class designed to give a quick preliminary estimate of characteristics of various time series. As this takes place, statistical parameters and autocorrelation function are estimated, a spectral estimation of time series is carried out and a histogram is built.
Graphical Interfaces II: the Menu Item Element (Chapter 1)
Graphical Interfaces II: the Menu Item Element (Chapter 1)

Graphical Interfaces II: the Menu Item Element (Chapter 1)

In the second part of the series, we will show in detail the development of such interface elements as main menu and context menu. We will also mention drawing elements and create a special class for it. We will discuss in depth such question as managing program events including custom ones.
preview
Dealing with Time (Part 2): The Functions

Dealing with Time (Part 2): The Functions

Determing the broker offset and GMT automatically. Instead of asking the support of your broker, from whom you will probably receive an insufficient answer (who would be willing to explain a missing hour), we simply look ourselves how they time their prices in the weeks of the time changes — but not cumbersome by hand, we let a program do it — why do we have a PC after all.
Social Trading. Can a profitable signal be made even better?
Social Trading. Can a profitable signal be made even better?

Social Trading. Can a profitable signal be made even better?

Most subscribers choose a trade signal by the beauty of the balance curve and by the number of subscribers. This is why many today's providers care of beautiful statistics rather than of real signal quality, often playing with lot sizes and artificially reducing the balance curve to an ideal appearance. This paper deals with the reliability criteria and the methods a provider may use to enhance its signal quality. An exemplary analysis of a specific signal history is presented, as well as methods that would help a provider to make it more profitable and less risky.
MQL5 Cookbook: The History of Deals And Function Library for Getting Position Properties
MQL5 Cookbook: The History of Deals And Function Library for Getting Position Properties

MQL5 Cookbook: The History of Deals And Function Library for Getting Position Properties

It is time to briefly summarize the information provided in the previous articles on position properties. In this article, we will create a few additional functions to get the properties that can only be obtained after accessing the history of deals. We will also get familiar with data structures that will allow us to access position and symbol properties in a more convenient way.
A Few Tips for First-Time Customers
A Few Tips for First-Time Customers

A Few Tips for First-Time Customers

A proverbial wisdom often attributed to various famous people says: "He who makes no mistakes never makes anything." Unless you consider idleness itself a mistake, this statement is hard to argue with. But you can always analyze the past mistakes (your own and of others) to minimize the number of your future mistakes. We are going to attempt to review possible situations arising when executing jobs in the same-name service.
Create your own Market Watch using the Standard Library Classes
Create your own Market Watch using the Standard Library Classes

Create your own Market Watch using the Standard Library Classes

The new MetaTrader 5 client terminal and the MQL5 Language provides new opportunities for presenting visual information to the trader. In this article, we propose a universal and extensible set of classes, which handles all the work of organizing displaying of the arbitrary text information on the chart. The example of Market Watch indicator is presented.