MQL4 and 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
Trading DiNapoli levels
Trading DiNapoli levels

Trading DiNapoli levels

The article considers one of the variants for Expert Advisor practical realization to trade DiNapoli levels using MQL5 standard tools. Its performance is tested and conclusions are made.
Creating a new trading strategy using a technology of resolving entries into indicators
Creating a new trading strategy using a technology of resolving entries into indicators

Creating a new trading strategy using a technology of resolving entries into indicators

The article suggests a technology helping everyone to create custom trading strategies by assembling an individual indicator set, as well as to develop custom market entry signals.
Resolving entries into indicators
Resolving entries into indicators

Resolving entries into indicators

Different situations happen in trader’s life. Often, the history of successful trades allows us to restore a strategy, while looking at a loss history we try to develop and improve it. In both cases, we compare trades with known indicators. This article suggests methods of batch comparison of trades with a number of indicators.
Using the Kalman Filter for price direction prediction
Using the Kalman Filter for price direction prediction

Using the Kalman Filter for price direction prediction

For successful trading, we almost always need indicators that can separate the main price movement from noise fluctuations. In this article, we consider one of the most promising digital filters, the Kalman filter. The article provides the description of how to draw and use the filter.
R-squared as an estimation of quality of the strategy balance curve
R-squared as an estimation of quality of the strategy balance curve

R-squared as an estimation of quality of the strategy balance curve

This article describes the construction of the custom optimization criterion R-squared. This criterion can be used to estimate the quality of a strategy's balance curve and to select the most smoothly growing and stable strategies. The work discusses the principles of its construction and statistical methods used in estimation of properties and quality of this metric.
Comparing different types of moving averages in trading
Comparing different types of moving averages in trading

Comparing different types of moving averages in trading

This article deals with seven types of moving averages (MA) and a trading strategy to work with them. We also test and compare various MAs at a single trading strategy and evaluate the efficiency of each moving average compared to others.
Triangular arbitrage
Triangular arbitrage

Triangular arbitrage

The article deals with the popular trading method - triangular arbitrage. Here we analyze the topic in as much detail as possible, consider the positive and negative aspects of the strategy and develop the ready-made Expert Advisor code.
Mini Market Emulator or Manual Strategy Tester
Mini Market Emulator or Manual Strategy Tester

Mini Market Emulator or Manual Strategy Tester

Mini Market Emulator is an indicator designed for partial emulation of work in the terminal. Presumably, it can be used to test "manual" strategies of market analysis and trading.
Fuzzy Logic in trading strategies
Fuzzy Logic in trading strategies

Fuzzy Logic in trading strategies

The article considers an example of applying the fuzzy logic to build a simple trading system, using the Fuzzy library. Variants for improving the system by combining fuzzy logic, genetic algorithms and neural networks are proposed.
A New Approach to Interpreting Classic and Hidden Divergence
A New Approach to Interpreting Classic and Hidden Divergence

A New Approach to Interpreting Classic and Hidden Divergence

The article considers the classic method for divergence construction and provides an additional divergence interpretation method. A trading strategy was developed based on this new interpretation method. This strategy is also described in the article.
Optimizing a strategy using balance graph and comparing results with "Balance + max Sharpe Ratio" criterion
Optimizing a strategy using balance graph and comparing results with "Balance + max Sharpe Ratio" criterion

Optimizing a strategy using balance graph and comparing results with "Balance + max Sharpe Ratio" criterion

In this article, we consider yet another custom trading strategy optimization criterion based on the balance graph analysis. The linear regression is calculated using the function from the ALGLIB library.
Practical evaluation of the adaptive market following method
Practical evaluation of the adaptive market following method

Practical evaluation of the adaptive market following method

The main difference of the trading system proposed in the article is the use of mathematical tools for analyzing stock quotes. The system applies digital filtering and spectral estimation of discrete time series. The theoretical aspects of the strategy are described and a test Expert Advisor is created.
Implementing a Scalping Market Depth Using the CGraphic Library
Implementing a Scalping Market Depth Using the CGraphic Library

Implementing a Scalping Market Depth Using the CGraphic Library

In this article, we will create the basic functionality of a scalping Market Depth tool. Also, we will develop a tick chart based on the CGraphic library and integrate it with the order book. Using the described Market Depth, it will be possible to create a powerful assistant tool for short-term trading.
Auto search for divergences and convergences
Auto search for divergences and convergences

Auto search for divergences and convergences

The article considers all kinds of divergence: simple, hidden, extended, triple, quadruple, convergence, as well as divergences of A, B and C classes. A universal indicator for their search and display on the chart is developed.
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.
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.
Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)
Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)

Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)

A new version of the graphics library for creating scientific charts (the CGraphic class) has been presented recently. This update of the developed library for creating graphical interfaces will introduce a version with a new control for creating charts. Now it is even easier to visualize data of different types.
Risk Evaluation in the Sequence of Deals with One Asset
Risk Evaluation in the Sequence of Deals with One Asset

Risk Evaluation in the Sequence of Deals with One Asset

This article describes the use of methods of the theory of probability and mathematical statistics in the analysis of trading systems.
TradeObjects: Automation of trading based on MetaTrader graphical objects
TradeObjects: Automation of trading based on MetaTrader graphical objects

TradeObjects: Automation of trading based on MetaTrader graphical objects

The article deals with a simple approach to creating an automated trading system based on the chart linear markup and offers a ready-made Expert Advisor using the standard properties of the MetaTrader 4 and 5 objects and supporting the main trading operations.
Deep Neural Networks (Part IV). Creating, training and testing a model of neural network
Deep Neural Networks (Part IV). Creating, training and testing a model of neural network

Deep Neural Networks (Part IV). Creating, training and testing a model of neural network

This article considers new capabilities of the darch package (v.0.12.0). It contains a description of training of a deep neural networks with different data types, different structure and training sequence. Training results are included.
Cross-Platform Expert Advisor: Custom Stops, Breakeven and Trailing
Cross-Platform Expert Advisor: Custom Stops, Breakeven and Trailing

Cross-Platform Expert Advisor: Custom Stops, Breakeven and Trailing

This article discusses how custom stop levels can be set up in a cross-platform expert advisor. It also discusses a closely-related method by which the evolution of a stop level over time can be defined.
Deep Neural Networks (Part III). Sample selection and dimensionality reduction
Deep Neural Networks (Part III). Sample selection and dimensionality reduction

Deep Neural Networks (Part III). Sample selection and dimensionality reduction

This article is a continuation of the series of articles about deep neural networks. Here we will consider selecting samples (removing noise), reducing the dimensionality of input data and dividing the data set into the train/val/test sets during data preparation for training the neural network.
Using cloud storage services for data exchange between terminals
Using cloud storage services for data exchange between terminals

Using cloud storage services for data exchange between terminals

Cloud technologies are becoming more popular. Nowadays, we can choose between paid and free storage services. Is it possible to use them in trading? This article proposes a technology for exchanging data between terminals using cloud storage services.
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.
Creating and testing custom symbols in MetaTrader 5
Creating and testing custom symbols in MetaTrader 5

Creating and testing custom symbols in MetaTrader 5

Creating custom symbols pushes the boundaries in the development of trading systems and financial market analysis. Now traders are able to plot charts and test trading strategies on an unlimited number of financial instruments.
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.
The Flag Pattern
The Flag Pattern

The Flag Pattern

The article provides the analysis of the following patterns: Flag, Pennant, Wedge, Rectangle, Contracting Triangle, Expanding Triangle. In addition to analyzing their similarities and differences, we will create indicators for detecting these patterns on the chart, as well as a tester indicator for the fast evaluation of their effectiveness.
Custom Walk Forward optimization in MetaTrader 5
Custom Walk Forward optimization in MetaTrader 5

Custom Walk Forward optimization in MetaTrader 5

The article deals with the approaches enabling accurate simulation of walk forward optimization using the built-in tester and auxiliary libraries implemented in MQL.
Deep Neural Networks (Part I). Preparing Data
Deep Neural Networks (Part I). Preparing Data

Deep Neural Networks (Part I). Preparing Data

This series of articles continues exploring deep neural networks (DNN), which are used in many application areas including trading. Here new dimensions of this theme will be explored along with testing of new methods and ideas using practical experiments. The first article of the series is dedicated to preparing data for DNN.
Cross-Platform Expert Advisor: Stops
Cross-Platform Expert Advisor: Stops

Cross-Platform Expert Advisor: Stops

This article discusses an implementation of stop levels in an expert advisor in order to make it compatible with the two platforms MetaTrader 4 and MetaTrader 5.
How to conduct a qualitative analysis of trading signals and select the best of them
How to conduct a qualitative analysis of trading signals and select the best of them

How to conduct a qualitative analysis of trading signals and select the best of them

The article deals with evaluating the performance of Signals Providers. We offer several additional parameters highlighting signal trading results from a slightly different angle than in traditional approaches. The concepts of the proper management and perfect deal are described. We also dwell on the optimal selection using the obtained results and compiling the portfolio of multiple signal sources.
Naive Bayes classifier for signals of a set of indicators
Naive Bayes classifier for signals of a set of indicators

Naive Bayes classifier for signals of a set of indicators

The article analyzes the application of the Bayes' formula for increasing the reliability of trading systems by means of using signals from multiple independent indicators. Theoretical calculations are verified with a simple universal EA, configured to work with arbitrary indicators.
Universal Expert Advisor: Accessing Symbol Properties (Part 8)
Universal Expert Advisor: Accessing Symbol Properties (Part 8)

Universal Expert Advisor: Accessing Symbol Properties (Part 8)

The eighth part of the article features the description of the CSymbol class, which is a special object that provides access to any trading instrument. When used inside an Expert Advisor, the class provides a wide set of symbol properties, while allowing to simplify Expert Advisor programming and to expand its functionality.
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.
Graphical Interfaces XI: Rendered controls (build 14.2)
Graphical Interfaces XI: Rendered controls (build 14.2)

Graphical Interfaces XI: Rendered controls (build 14.2)

In the new version of the library, all controls will be drawn on separate graphical objects of the OBJ_BITMAP_LABEL type. We will also continue to describe the optimization of code: changes in the core classes of the library will be discussed.
Angles in Trading. Further Study Required
Angles in Trading. Further Study Required

Angles in Trading. Further Study Required

In this article, we discuss the method of trading analysis by measuring angles in the MetaTrader 4 terminal. The article provides a general plan of using angles for trend movement analysis, as well as non-standard ways to the practical application of angle analysis in trading. The article also provides conclusions that can be useful for trading.
Patterns available when trading currency baskets. Part III
Patterns available when trading currency baskets. Part III

Patterns available when trading currency baskets. Part III

This is the final article devoted to the patterns that occur when trading currency pair baskets. It considers combined trend-following indicators and application of standard graphical constructions.
Graphical Interfaces XI: Refactoring the Library code (build 14.1)
Graphical Interfaces XI: Refactoring the Library code (build 14.1)

Graphical Interfaces XI: Refactoring the Library code (build 14.1)

As the library grows, its code must be optimized again in order to reduce its size. The version of the library described in this article has become even more object-oriented. This made the code easier to learn. A detailed description of the latest changes will allow the readers to develop the library independently based on their own needs.
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.
Creating Documentation Based on MQL5 Source Code
Creating Documentation Based on MQL5 Source Code

Creating Documentation Based on MQL5 Source Code

This article considers creation of documentation for MQL5 code starting with the automated markup of required tags. It also provides the description of how to use the Doxygen software, how to properly configure it and how to receive results in different formats, including html, HtmlHelp and PDF.