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
Testing currency pair patterns: Practical application and real trading perspectives. Part IV
Testing currency pair patterns: Practical application and real trading perspectives. Part IV

Testing currency pair patterns: Practical application and real trading perspectives. Part IV

This article concludes the series devoted to trading currency pair baskets. Here we test the remaining pattern and discuss applying the entire method in real trading. Market entries and exits, searching for patterns and analyzing them, complex use of combined indicators are considered.
Deep Neural Networks (Part VII). Ensemble of neural networks: stacking
Deep Neural Networks (Part VII). Ensemble of neural networks: stacking

Deep Neural Networks (Part VII). Ensemble of neural networks: stacking

We continue to build ensembles. This time, the bagging ensemble created earlier will be supplemented with a trainable combiner — a deep neural network. One neural network combines the 7 best ensemble outputs after pruning. The second one takes all 500 outputs of the ensemble as input, prunes and combines them. The neural networks will be built using the keras/TensorFlow package for Python. The features of the package will be briefly considered. Testing will be performed and the classification quality of bagging and stacking ensembles will be compared.
How to create Requirements Specification for ordering a trading robot
How to create Requirements Specification for ordering a trading robot

How to create Requirements Specification for ordering a trading robot

Are you trading using your own strategy? If your system rules can be formally described as software algorithms, it is better to entrust trading to an automated Expert Advisor. A robot does not need sleep or food and is not subject to human weaknesses. In this article, we show how to create Requirements Specification when ordering a trading robot in the Freelance service.
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.
Comparative analysis of 10 flat trading strategies
Comparative analysis of 10 flat trading strategies

Comparative analysis of 10 flat trading strategies

The article explores the advantages and disadvantages of trading in flat periods. The ten strategies created and tested within this article are based on the tracking of price movements inside a channel. Each strategy is provided with a filtering mechanism, which is aimed at avoiding false market entry signals.
Applying the Monte Carlo method for optimizing trading strategies
Applying the Monte Carlo method for optimizing trading strategies

Applying the Monte Carlo method for optimizing trading strategies

Before launching a robot on a trading account, we usually test and optimize it on quotes history. However, a reasonable question arises: how can past results help us in the future? The article describes applying the Monte Carlo method to construct custom criteria for trading strategy optimization. In addition, the EA stability criteria are considered.
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.
How to analyze the trades of the Signal selected in the chart
How to analyze the trades of the Signal selected in the chart

How to analyze the trades of the Signal selected in the chart

The trade Signals service develops in leaps and bounds. Trusting our funds to a signal provider, we would like to minimize the risk of losing our deposit. So how to puzzle out in this forest of trade signals? How to find the one that would produce profits? This paper proposes to create a tool for visually analyzing the history of trades on trade signals in a symbol chart.
Improving Panels: Adding transparency, changing background color and inheriting from CAppDialog/CWndClient
Improving Panels: Adding transparency, changing background color and inheriting from CAppDialog/CWndClient

Improving Panels: Adding transparency, changing background color and inheriting from CAppDialog/CWndClient

In this article, we continue studying the use of CAppDialog. Now we will learn how to set color for the background, borders and header of the dialog box. Also, this article provides a step-by-step description of how to add transparency for an application window when dragging it within the chart. We will consider how to create child classes of CAppDialog or CWndClient and analyze new specifics of working with controls. Finally, we will review new Projects from a new perspective.
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.
Visual strategy builder. Creating trading robots without programming
Visual strategy builder. Creating trading robots without programming

Visual strategy builder. Creating trading robots without programming

This article presents a visual strategy builder. It is shown how any user can create trading robots and utilities without programming. Created Expert Advisors are fully functional and can be tested in the strategy tester, optimized in the cloud or executed live on real time charts.
Developing the oscillator-based ZigZag indicator. Example of executing a requirements specification
Developing the oscillator-based ZigZag indicator. Example of executing a requirements specification

Developing the oscillator-based ZigZag indicator. Example of executing a requirements specification

The article demonstrates the development of the ZigZag indicator in accordance with one of the sample specifications described in the article "How to prepare Requirements Specification when ordering an indicator". The indicator is built by extreme values defined using an oscillator. There is an ability to use one of five oscillators: WPR, CCI, Chaikin, RSI or Stochastic Oscillator.
Processing optimization results using the graphical interface
Processing optimization results using the graphical interface

Processing optimization results using the graphical interface

This is a continuation of the idea of processing and analysis of optimization results. This time, our purpose is to select the 100 best optimization results and display them in a GUI table. The user will be able to select a row in the optimization results table and receive a multi-symbol balance and drawdown graph on separate charts.
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.
ZUP - Universal ZigZag with Pesavento patterns. Search for patterns
ZUP - Universal ZigZag with Pesavento patterns. Search for patterns

ZUP - Universal ZigZag with Pesavento patterns. Search for patterns

The ZUP indicator platform allows searching for multiple known patterns, parameters for which have already been set. These parameters can be edited to suit your requirements. You can also create new patterns using the ZUP graphical interfaces and save their parameters to a file. After that you can quickly check, whether these new patterns can be found on charts.
Synchronizing several same-symbol charts on different timeframes
Synchronizing several same-symbol charts on different timeframes

Synchronizing several same-symbol charts on different timeframes

When making trading decisions, we often have to analyze charts on several timeframes. At the same time, these charts often contain graphical objects. Applying the same objects to all charts is inconvenient. In this article, I propose to automate cloning of objects to be displayed on charts.
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.
Deep Neural Networks (Part V). Bayesian optimization of DNN hyperparameters
Deep Neural Networks (Part V). Bayesian optimization of DNN hyperparameters

Deep Neural Networks (Part V). Bayesian optimization of DNN hyperparameters

The article considers the possibility to apply Bayesian optimization to hyperparameters of deep neural networks, obtained by various training variants. The classification quality of a DNN with the optimal hyperparameters in different training variants is compared. Depth of effectiveness of the DNN optimal hyperparameters has been checked in forward tests. The possible directions for improving the classification quality have been determined.
Comparing speeds of self-caching indicators
Comparing speeds of self-caching indicators

Comparing speeds of self-caching indicators

The article compares the classic MQL5 access to indicators with alternative MQL4-style methods. Several varieties of MQL4-style access to indicators are considered: with and without the indicator handles caching. Considering the indicator handles inside the MQL5 core is analyzed as well.
preview
How to create a graphical panel of any complexity level

How to create a graphical panel of any complexity level

The article features a detailed explanation of how to create a panel on the basis of the CAppDialog class and how to add controls to the panel. It provides the description of the panel structure and a scheme, which shows the inheritance of objects. From this article, you will also learn how events are handled and how they are delivered to dependent controls. Additional examples show how to edit panel parameters, such as the size and the background color.
Visualizing trading strategy optimization in MetaTrader 5
Visualizing trading strategy optimization in MetaTrader 5

Visualizing trading strategy optimization in MetaTrader 5

The article implements an MQL application with a graphical interface for extended visualization of the optimization process. The graphical interface applies the last version of EasyAndFast library. Many users may ask why they need graphical interfaces in MQL applications. This article demonstrates one of multiple cases where they can be useful for traders.
How to create Requirements Specification for ordering an indicator
How to create Requirements Specification for ordering an indicator

How to create Requirements Specification for ordering an indicator

Most often the first step in the development of a trading system is the creation of a technical indicator, which can identify favorable market behavior patterns. A professionally developed indicator can be ordered from the Freelance service. From this article you will learn how to create a proper Requirements Specification, which will help you to obtain the desired indicator faster.
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.
LifeHack for traders: Blending ForEach with defines (#define)
LifeHack for traders: Blending ForEach with defines (#define)

LifeHack for traders: Blending ForEach with defines (#define)

The article is an intermediate step for those who still writes in MQL4 and has no desire to switch to MQL5. We continue to search for opportunities to write code in MQL4 style. This time, we will look into the macro substitution of the #define preprocessor.
Controlled optimization: Simulated annealing
Controlled optimization: Simulated annealing

Controlled optimization: Simulated annealing

The Strategy Tester in the MetaTrader 5 trading platform provides only two optimization options: complete search of parameters and genetic algorithm. This article proposes a new method for optimizing trading strategies — Simulated annealing. The method's algorithm, its implementation and integration into any Expert Advisor are considered. The developed algorithm is tested on the Moving Average EA.
LifeHack for traders: Fast food made of indicators
LifeHack for traders: Fast food made of indicators

LifeHack for traders: Fast food made of indicators

If you have newly switched to MQL5, then this article will be useful. First, the access to the indicator data and series is done in the usual MQL4 style. Second, this entire simplicity is implemented in MQL5. All functions are as clear as possible and perfectly suited for step-by-step debugging.
Custom Strategy Tester based on fast mathematical calculations
Custom Strategy Tester based on fast mathematical calculations

Custom Strategy Tester based on fast mathematical calculations

The article describes the way to create a custom strategy tester and a custom analyzer of the optimization passes. After reading it, you will understand how the math calculations mode and the mechanism of so-called frames work, how to prepare and load custom data for calculations and use effective algorithms for their compression. This article will also be interesting to those interested in ways of storing custom information within an expert.
Automatic construction of support and resistance lines
Automatic construction of support and resistance lines

Automatic construction of support and resistance lines

The article deals with automatic construction of support/resistance lines using local tops and bottoms of price charts. The well-known ZigZag indicator is applied to define these extreme values.
Testing patterns that arise when trading currency pair baskets. Part III
Testing patterns that arise when trading currency pair baskets. Part III

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

In this article, we finish testing the patterns that can be detected when trading currency pair baskets. Here we present the results of testing the patterns tracking the movement of pair's currencies relative to each other.
The Channel Breakout pattern
The Channel Breakout pattern

The Channel Breakout pattern

Price trends form price channels that can be observed on financial symbol charts. The breakout of the current channel is one of the strong trend reversal signals. In this article, I suggest a way to automate the process of finding such signals and see if the channel breakout pattern can be used for creating a trading strategy.
How to reduce trader's risks
How to reduce trader's risks

How to reduce trader's risks

Trading in financial markets is associated with a whole range of risks that should be taken into account in the algorithms of trading systems. Reducing such risks is the most important task to make a profit when trading.
Automatic Selection of Promising Signals
Automatic Selection of Promising Signals

Automatic Selection of Promising Signals

The article is devoted to the analysis of trading signals for the MetaTrader 5 platform, which enable the automated execution of trading operations on subscribers' accounts. Also, the article considers the development of tools, which help search for potentially promising trading signals straight from the terminal.
Risk Evaluation in the Sequence of Deals with One Asset. Continued
Risk Evaluation in the Sequence of Deals with One Asset. Continued

Risk Evaluation in the Sequence of Deals with One Asset. Continued

The article develops the ideas proposed in the previous part and considers them further. It describes the problems of yield distributions, plotting and studying statistical regularities.
Night trading during the Asian session: How to stay profitable
Night trading during the Asian session: How to stay profitable

Night trading during the Asian session: How to stay profitable

The article deals with the concept of night trading, as well as trading strategies and their implementation in MQL5. We perform tests and make appropriate conclusions.
Momentum Pinball trading strategy
Momentum Pinball trading strategy

Momentum Pinball trading strategy

In this article, we continue to consider writing the code to trading systems described in a book by Linda B. Raschke and Laurence A. Connors “Street Smarts: High Probability Short-Term Trading Strategies”. This time we study Momentum Pinball system: there is described creation of two indicators, trade robot and signal block on it.
Creating a custom news feed for MetaTrader 5
Creating a custom news feed for MetaTrader 5

Creating a custom news feed for MetaTrader 5

In this article we look at the possibility of creating a flexible news feed that offers more options in terms of the type of news and also its source. The article will show how a web API can be integrated with the MetaTrader 5 terminal.
The NRTR indicator and trading modules based on NRTR for the MQL5 Wizard
The NRTR indicator and trading modules based on NRTR for the MQL5 Wizard

The NRTR indicator and trading modules based on NRTR for the MQL5 Wizard

In this article we are going to analyze the NRTR indicator and create a trading system based on this indicator. We are going to develop a module of trading signals that can be used in creating strategies based on a combination of NRTR with additional trend confirmation indicators.
Testing patterns that arise when trading currency pair baskets. Part II
Testing patterns that arise when trading currency pair baskets. Part II

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

We continue testing the patterns and trying the methods described in the articles about trading currency pair baskets. Let's consider in practice, whether it is possible to use the patterns of the combined WPR graph crossing the moving average. If the answer is yes, we should consider the appropriate usage methods.