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
Evaluation and selection of variables for machine learning models
Evaluation and selection of variables for machine learning models

Evaluation and selection of variables for machine learning models

This article focuses on specifics of choice, preconditioning and evaluation of the input variables (predictors) for use in machine learning models. New approaches and opportunities of deep predictor analysis and their influence on possible overfitting of models will be considered. The overall result of using models largely depends on the result of this stage. We will analyze two packages offering new and original approaches to the selection of predictors.
Creating Tick Indicators in MQL5
Creating Tick Indicators in MQL5

Creating Tick Indicators in MQL5

In this article, we will consider the creation of two indicators: the tick indicator, which plots the tick chart of the price and tick candle indicator, which plot candles with the specified number of ticks. Each of the indicators writes the incoming prices into a file, and uses the saved data after the restart of the indicator (these data also can be used by the other programs)
preview
OpenCL: From Naive Towards More Insightful Programming

OpenCL: From Naive Towards More Insightful Programming

This article focuses on some optimization capabilities that open up when at least some consideration is given to the underlying hardware on which the OpenCL kernel is executed. The figures obtained are far from being ceiling values but even they suggest that having the existing resources available here and now (OpenCL API as implemented by the developers of the terminal does not allow to control some parameters important for optimization - particularly, the work group size), the performance gain over the host program execution is very substantial.
MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window
MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window

MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window

There are 21 time frames available in MetaTrader 5 for analysis. You can take advantage of special chart objects that you can place on the existing chart and set the symbol, time frame and some other properties right there. This article will provide detailed information on such chart graphical objects: we will create an indicator with controls (buttons) that will allow us to set multiple chart objects in a subwindow at the same time. Furthermore, chart objects will accurately fit in the subwindow and will be automatically adjusted when the main chart or terminal window is resized.
Indicator for Constructing a Three Line Break Chart
Indicator for Constructing a Three Line Break Chart

Indicator for Constructing a Three Line Break Chart

This article is dedicated to the Three Line Break chart, suggested by Steve Nison in his book "Beyond Candlesticks". The greatest advantage of this chart is that it allows filtering minor fluctuations of a price in relation to the previous movement. We are going to discuss the principle of the chart construction, the code of the indicator and some examples of trading strategies based on it.
Genetic Algorithms - It's Easy!
Genetic Algorithms - It's Easy!

Genetic Algorithms - It's Easy!

In this article the author talks about evolutionary calculations with the use of a personally developed genetic algorithm. He demonstrates the functioning of the algorithm, using examples, and provides practical recommendations for its usage.
Exploring Seasonal Patterns of Financial Time Series with Boxplot
Exploring Seasonal Patterns of Financial Time Series with Boxplot

Exploring Seasonal Patterns of Financial Time Series with Boxplot

In this article we will view seasonal characteristics of financial time series using Boxplot diagrams. Each separate boxplot (or box-and-whiskey diagram) provides a good visualization of how values are distributed along the dataset. Boxplots should not be confused with the candlestick charts, although they can be visually similar.
Advanced Adaptive Indicators Theory and Implementation in MQL5
Advanced Adaptive Indicators Theory and Implementation in MQL5

Advanced Adaptive Indicators Theory and Implementation in MQL5

This article will describe advanced adaptive indicators and their implementation in MQL5: Adaptive Cyber Cycle, Adaptive Center of Gravity and Adaptive RVI. All indicators were originally presented in "Cybernetic Analysis for Stocks and Futures" by John F. Ehlers.
Machine Learning: How Support Vector Machines can be used in Trading
Machine Learning: How Support Vector Machines can be used in Trading

Machine Learning: How Support Vector Machines can be used in Trading

Support Vector Machines have long been used in fields such as bioinformatics and applied mathematics to assess complex data sets and extract useful patterns that can be used to classify data. This article looks at what a support vector machine is, how they work and why they can be so useful in extracting complex patterns. We then investigate how they can be applied to the market and potentially used to advise on trades. Using the Support Vector Machine Learning Tool, the article provides worked examples that allow readers to experiment with their own trading.
Plotting trend lines based on fractals using MQL4 and MQL5
Plotting trend lines based on fractals using MQL4 and MQL5

Plotting trend lines based on fractals using MQL4 and MQL5

The article describes the automation of trend lines plotting based on the Fractals indicator using MQL4 and MQL5. The article structure provides a comparative view of the solution for two languages. Trend lines are plotted using two last known fractals.
Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs
Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs

Tips from a professional programmer (Part II): Storing and exchanging parameters between an Expert Advisor, scripts and external programs

These are some tips from a professional programmer about methods, techniques and auxiliary tools which can make programming easier. We will discuss parameters which can be restored after terminal restart (shutdown). All examples are real working code segments from my Cayman project.
Strategy builder based on Merrill patterns
Strategy builder based on Merrill patterns

Strategy builder based on Merrill patterns

In the previous article, we considered application of Merrill patterns to various data, such as to a price value on a currency symbol chart and values of standard MetaTrader 5 indicators: ATR, WPR, CCI, RSI, among others. Now, let us try to create a strategy construction set based on Merrill patterns.
Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator
Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator

Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator

The article describes a method of automated creation of neural network EAs using MQL5 Wizard and Hlaiman EA Generator. It shows you how you can easily start working with neural networks, without having to learn the entire body of theoretical information and writing your own code.
Timeseries in DoEasy library (part 42): Abstract indicator buffer object class
Timeseries in DoEasy library (part 42): Abstract indicator buffer object class

Timeseries in DoEasy library (part 42): Abstract indicator buffer object class

In this article, we start the development of the indicator buffer classes for the DoEasy library. We will create the base class of the abstract buffer which is to be used as a foundation for the development of different class types of indicator buffers.
The Basics of Object-Oriented Programming
The Basics of Object-Oriented Programming

The Basics of Object-Oriented Programming

You don't need to know what are polymorphism, encapsulation, etc. all about in to use object-oriented programming (OOP)... you may simply use these features. This article covers the basics of OOP with hands-on examples.
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.
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.
Debugging MQL5 Programs
Debugging MQL5 Programs

Debugging MQL5 Programs

This article is intended primarily for the programmers who have already learned the language but have not fully mastered the program development yet. It reveals some debugging techniques and presents a combined experience of the author and many other programmers.
Trading Signal Generator Based on a Custom Indicator
Trading Signal Generator Based on a Custom Indicator

Trading Signal Generator Based on a Custom Indicator

How to create a trading signal generator based on a custom indicator? How to create a custom indicator? How to get access to custom indicator data? Why do we need the IS_PATTERN_USAGE(0) structure and model 0?
Creating Active Control Panels in MQL5 for Trading
Creating Active Control Panels in MQL5 for Trading

Creating Active Control Panels in MQL5 for Trading

The article covers the problem of development of active control panels in MQL5. Interface elements are managed by the event handling mechanism. Besides, the option of a flexible setup of control elements properties is available. The active control panel allows working with positions, as well setting, modifying and deleting market and pending orders.
preview
Learn Why and How to Design Your Algorithmic Trading System

Learn Why and How to Design Your Algorithmic Trading System

This article shows the basics of MQL for beginners to design their Algorithmic trading system (Expert Advisor) through designing a simple algorithmic trading system after mentioning some basics of MQL5
Create Your Own Expert Advisor in MQL5 Wizard
Create Your Own Expert Advisor in MQL5 Wizard

Create Your Own Expert Advisor in MQL5 Wizard

The knowledge of programming languages is no longer a prerequisite for creating trading robots. Earlier lack of programming skills was an impassable obstacle to the implementation of one's own trading strategies, but with the emergence of the MQL5 Wizard, the situation radically changed. Novice traders can stop worrying because of the lack of programming experience - with the new Wizard, which allows you to generate Expert Advisor code, it is not necessary.
Universal Trend with the Graphical Interface
Universal Trend with the Graphical Interface

Universal Trend with the Graphical Interface

In this article a universal trend indicator is created based on a number of standard indicators. An additionally created graphical interface allows selecting the type of indicator and adjusting its parameter. The indicator is displayed in a separate window with rows of colored icons.
3D Modeling in MQL5
3D Modeling in MQL5

3D Modeling in MQL5

A time series is a dynamic system, in which values of a random variable are received continuously or at successive equally spaced points in time. Transition from 2D to 3D market analysis provides a new look at complex processes and research objects. The article describes visualization methods providing 3D representation of two-dimensional data.
How Long Is the Trend?
How Long Is the Trend?

How Long Is the Trend?

The article highlights several methods for trend identification aiming to determine the trend duration relative to the flat market. In theory, the trend to flat rate is considered to be 30% to 70%. This is what we'll be checking.
Developing stock indicators featuring volume control through the example of the delta indicator
Developing stock indicators featuring volume control through the example of the delta indicator

Developing stock indicators featuring volume control through the example of the delta indicator

The article deals with the algorithm of developing stock indicators based on real volumes using the CopyTicks() and CopyTicksRange() functions. Some subtle aspects of developing such indicators, as well as their operation in real time and in the strategy tester are also described.
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.
Graphics in DoEasy library (Part 88): Graphical object collection — two-dimensional dynamic array for storing dynamically changing object properties
Graphics in DoEasy library (Part 88): Graphical object collection — two-dimensional dynamic array for storing dynamically changing object properties

Graphics in DoEasy library (Part 88): Graphical object collection — two-dimensional dynamic array for storing dynamically changing object properties

In this article, I will create a dynamic multidimensional array class with the ability to change the amount of data in any dimension. Based on the created class, I will create a two-dimensional dynamic array to store some dynamically changed properties of graphical objects.
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.
Library for easy and quick development of MetaTrader programs (part XV): Collection of symbol objects
Library for easy and quick development of MetaTrader programs (part XV): Collection of symbol objects

Library for easy and quick development of MetaTrader programs (part XV): Collection of symbol objects

In this article, we will consider creation of a symbol collection based on the abstract symbol object developed in the previous article. The abstract symbol descendants are to clarify a symbol data and define the availability of the basic symbol object properties in a program. Such symbol objects are to be distinguished by their affiliation with groups.
Library for easy and quick development of MetaTrader programs (part XX): Creating and storing program resources
Library for easy and quick development of MetaTrader programs (part XX): Creating and storing program resources

Library for easy and quick development of MetaTrader programs (part XX): Creating and storing program resources

The article deals with storing data in the program's source code and creating audio and graphical files out of them. When developing an application, we often need audio and images. The MQL language features several methods of using such data.
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.
Library for easy and quick development of MetaTrader programs (part I). Concept, data management and first results
Library for easy and quick development of MetaTrader programs (part I). Concept, data management and first results

Library for easy and quick development of MetaTrader programs (part I). Concept, data management and first results

While analyzing a huge number of trading strategies, orders for development of applications for MetaTrader 5 and MetaTrader 4 terminals and various MetaTrader websites, I came to the conclusion that all this diversity is based mostly on the same elementary functions, actions and values appearing regularly in different programs. This resulted in DoEasy cross-platform library for easy and quick development of МetaТrader 5 and МetaТrader 4 applications.
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.
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.
Library for easy and quick development of MetaTrader programs (part XXXII): Pending trading requests - placing orders under certain conditions
Library for easy and quick development of MetaTrader programs (part XXXII): Pending trading requests - placing orders under certain conditions

Library for easy and quick development of MetaTrader programs (part XXXII): Pending trading requests - placing orders under certain conditions

We continue the development of the functionality allowing users to trade using pending requests. In this article, we are going to implement the ability to place pending orders under certain conditions.
Deep Neural Networks (Part VIII). Increasing the classification quality of bagging ensembles
Deep Neural Networks (Part VIII). Increasing the classification quality of bagging ensembles

Deep Neural Networks (Part VIII). Increasing the classification quality of bagging ensembles

The article considers three methods which can be used to increase the classification quality of bagging ensembles, and their efficiency is estimated. The effects of optimization of the ELM neural network hyperparameters and postprocessing parameters are evaluated.
Library for easy and quick development of MetaTrader programs (part XXIX): Pending trading requests - request object classes
Library for easy and quick development of MetaTrader programs (part XXIX): Pending trading requests - request object classes

Library for easy and quick development of MetaTrader programs (part XXIX): Pending trading requests - request object classes

In the previous articles, we checked the concept of pending trading requests. A pending request is, in fact, a common trading order executed by a certain condition. In this article, we are going to create full-fledged classes of pending request objects — a base request object and its descendants.
MQL5 Cookbook: Implementing Your Own Depth of Market
MQL5 Cookbook: Implementing Your Own Depth of Market

MQL5 Cookbook: Implementing Your Own Depth of Market

This article demonstrates how to utilize Depth of Market (DOM) programmatically and describes the operation principle of CMarketBook class, that can expand the Standard Library of MQL5 classes and offer convenient methods of using DOM.
Thomas DeMark's Sequential (TD SEQUENTIAL) using artificial intelligence
Thomas DeMark's Sequential (TD SEQUENTIAL) using artificial intelligence

Thomas DeMark's Sequential (TD SEQUENTIAL) using artificial intelligence

In this article, I will tell you how to successfully trade by merging a very well-known strategy and a neural network. It will be about the Thomas DeMark's Sequential strategy with the use of an artificial intelligence system. Only the first part of the strategy will be applied, using the Setup and Intersection signals.