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
preview
Alan Andrews and his methods of time series analysis

Alan Andrews and his methods of time series analysis

Alan Andrews is one of the most famous "educators" of the modern world in the field of trading. His "pitchfork" is included in almost all modern quote analysis programs. But most traders do not use even a fraction of the opportunities that this tool provides. Besides, Andrews' original training course includes a description not only of the pitchfork (although it remains the main tool), but also of some other useful constructions. The article provides an insight into the marvelous chart analysis methods that Andrews taught in his original course. Beware, there will be a lot of images.
preview
How to use ONNX models in MQL5

How to use ONNX models in MQL5

ONNX (Open Neural Network Exchange) is an open format built to represent machine learning models. In this article, we will consider how to create a CNN-LSTM model to forecast financial timeseries. We will also show how to use the created ONNX model in an MQL5 Expert Advisor.
preview
Implementing the Janus factor in MQL5

Implementing the Janus factor in MQL5

Gary Anderson developed a method of market analysis based on a theory he dubbed the Janus Factor. The theory describes a set of indicators that can be used to reveal trends and assess market risk. In this article we will implement these tools in mql5.
preview
Category Theory in MQL5 (Part 5): Equalizers

Category Theory in MQL5 (Part 5): Equalizers

Category Theory is a diverse and expanding branch of Mathematics which is only recently getting some coverage in the MQL5 community. These series of articles look to explore and examine some of its concepts & axioms with the overall goal of establishing an open library that provides insight while also hopefully furthering the use of this remarkable field in Traders' strategy development.
preview
How to use MQL5 to detect candlesticks patterns

How to use MQL5 to detect candlesticks patterns

A new article to learn how to detect candlesticks patterns on prices automatically by MQL5.
preview
Moral expectation in trading

Moral expectation in trading

This article is about moral expectation. We will look at several examples of its use in trading, as well as the results that can be achieved with its help.
preview
Canvas based indicators: Filling channels with transparency

Canvas based indicators: Filling channels with transparency

In this article I'll introduce a method for creating custom indicators whose drawings are made using the class CCanvas from standard library and see charts properties for coordinates conversion. I'll approach specially indicators which need to fill the area between two lines using transparency.
preview
Neural networks made easy (Part 35): Intrinsic Curiosity Module

Neural networks made easy (Part 35): Intrinsic Curiosity Module

We continue to study reinforcement learning algorithms. All the algorithms we have considered so far required the creation of a reward policy to enable the agent to evaluate each of its actions at each transition from one system state to another. However, this approach is rather artificial. In practice, there is some time lag between an action and a reward. In this article, we will get acquainted with a model training algorithm which can work with various time delays from the action to the reward.
preview
Creating a comprehensive Owl trading strategy

Creating a comprehensive Owl trading strategy

My strategy is based on the classic trading fundamentals and the refinement of indicators that are widely used in all types of markets. This is a ready-made tool allowing you to follow the proposed new profitable trading strategy.
preview
Category Theory in MQL5 (Part 4): Spans, Experiments, and Compositions

Category Theory in MQL5 (Part 4): Spans, Experiments, and Compositions

Category Theory is a diverse and expanding branch of Mathematics which as of yet is relatively uncovered in the MQL5 community. These series of articles look to introduce and examine some of its concepts with the overall goal of establishing an open library that provides insight while hopefully furthering the use of this remarkable field in Traders' strategy development.
preview
Creating an EA that works automatically (Part 08): OnTradeTransaction

Creating an EA that works automatically (Part 08): OnTradeTransaction

In this article, we will see how to use the event handling system to quickly and efficiently process issues related to the order system. With this system the EA will work faster, so that it will not have to constantly search for the required data.
preview
Data Science and Machine Learning(Part 14): Finding Your Way in the Markets with Kohonen Maps

Data Science and Machine Learning(Part 14): Finding Your Way in the Markets with Kohonen Maps

Are you looking for a cutting-edge approach to trading that can help you navigate complex and ever-changing markets? Look no further than Kohonen maps, an innovative form of artificial neural networks that can help you uncover hidden patterns and trends in market data. In this article, we'll explore how Kohonen maps work, and how they can be used to develop smarter, more effective trading strategies. Whether you're a seasoned trader or just starting out, you won't want to miss this exciting new approach to trading.
preview
Neural networks made easy (Part 34): Fully Parameterized Quantile Function

Neural networks made easy (Part 34): Fully Parameterized Quantile Function

We continue studying distributed Q-learning algorithms. In previous articles, we have considered distributed and quantile Q-learning algorithms. In the first algorithm, we trained the probabilities of given ranges of values. In the second algorithm, we trained ranges with a given probability. In both of them, we used a priori knowledge of one distribution and trained another one. In this article, we will consider an algorithm which allows the model to train for both distributions.
preview
Testing and optimization of binary options strategies in MetaTrader 5

Testing and optimization of binary options strategies in MetaTrader 5

In this article, I will check and optimize binary options strategies in MetaTrader 5.
preview
Learn how to design a trading system by Fibonacci

Learn how to design a trading system by Fibonacci

In this article, we will continue our series of creating a trading system based on the most popular technical indicator. Here is a new technical tool which is the Fibonacci and we will learn how to design a trading system based on this technical indicator.
preview
Data Science and Machine Learning (Part 13): Improve your financial market analysis with Principal Component Analysis (PCA)

Data Science and Machine Learning (Part 13): Improve your financial market analysis with Principal Component Analysis (PCA)

Revolutionize your financial market analysis with Principal Component Analysis (PCA)! Discover how this powerful technique can unlock hidden patterns in your data, uncover latent market trends, and optimize your investment strategies. In this article, we explore how PCA can provide a new lens for analyzing complex financial data, revealing insights that would be missed by traditional approaches. Find out how applying PCA to financial market data can give you a competitive edge and help you stay ahead of the curve
preview
Creating an EA that works automatically (Part 07): Account types (II)

Creating an EA that works automatically (Part 07): Account types (II)

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. The trader should always be aware of what the automatic EA is doing, so that if it "goes off the rails", the trader could remove it from the chart as soon as possible and take control of the situation.
preview
Neural networks made easy (Part 33): Quantile regression in distributed Q-learning

Neural networks made easy (Part 33): Quantile regression in distributed Q-learning

We continue studying distributed Q-learning. Today we will look at this approach from the other side. We will consider the possibility of using quantile regression to solve price prediction tasks.
preview
MQL5 Cookbook — Macroeconomic events database

MQL5 Cookbook — Macroeconomic events database

The article discusses the possibilities of handling databases based on the SQLite engine. The CDatabase class has been formed for convenience and efficient use of OOP principles. It is subsequently involved in the creation and management of the database of macroeconomic events. The article provides the examples of using multiple methods of the CDatabase class.
preview
Creating an EA that works automatically (Part 06): Account types (I)

Creating an EA that works automatically (Part 06): Account types (I)

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. Our EA in its current state can work in any situation but it is not yet ready for automation. We still have to work on a few points.
preview
Data Science and Machine Learning (Part 12): Can Self-Training Neural Networks Help You Outsmart the Stock Market?

Data Science and Machine Learning (Part 12): Can Self-Training Neural Networks Help You Outsmart the Stock Market?

Are you tired of constantly trying to predict the stock market? Do you wish you had a crystal ball to help you make more informed investment decisions? Self-trained neural networks might be the solution you've been looking for. In this article, we explore whether these powerful algorithms can help you "ride the wave" and outsmart the stock market. By analyzing vast amounts of data and identifying patterns, self-trained neural networks can make predictions that are often more accurate than human traders. Discover how you can use this cutting-edge technology to maximize your profits and make smarter investment decisions.
preview
Population optimization algorithms: Bacterial Foraging Optimization (BFO)

Population optimization algorithms: Bacterial Foraging Optimization (BFO)

E. coli bacterium foraging strategy inspired scientists to create the BFO optimization algorithm. The algorithm contains original ideas and promising approaches to optimization and is worthy of further study.
preview
Data Science and Machine Learning (Part 11): Naïve Bayes, Probability theory in Trading

Data Science and Machine Learning (Part 11): Naïve Bayes, Probability theory in Trading

Trading with probability is like walking on a tightrope - it requires precision, balance, and a keen understanding of risk. In the world of trading, the probability is everything. It's the difference between success and failure, profit and loss. By leveraging the power of probability, traders can make informed decisions, manage risk effectively, and achieve their financial goals. So, whether you're a seasoned investor or a novice trader, understanding probability is the key to unlocking your trading potential. In this article, we'll explore the exciting world of trading with probability and show you how to take your trading game to the next level.
preview
Learn how to design a trading system by Bill Williams' MFI

Learn how to design a trading system by Bill Williams' MFI

This is a new article in the series in which we learn how to design a trading system based on popular technical indicators. This time we will cover Bill Williams' Market Facilitation Index (BW MFI).
preview
Category Theory in MQL5 (Part 3)

Category Theory in MQL5 (Part 3)

Category Theory is a diverse and expanding branch of Mathematics which as of yet is relatively uncovered in the MQL5 community. These series of articles look to introduce and examine some of its concepts with the overall goal of establishing an open library that provides insight while hopefully furthering the use of this remarkable field in Traders' strategy development.
preview
Revisiting Murray system

Revisiting Murray system

Graphical price analysis systems are deservedly popular among traders. In this article, I am going to describe the complete Murray system, including its famous levels, as well as some other useful techniques for assessing the current price position and making a trading decision.
preview
Creating an EA that works automatically (Part 05): Manual triggers (II)

Creating an EA that works automatically (Part 05): Manual triggers (II)

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. At the end of the previous article, I suggested that it would be appropriate to allow manual use of the EA, at least for a while.
preview
Creating an EA that works automatically (Part 04): Manual triggers (I)

Creating an EA that works automatically (Part 04): Manual triggers (I)

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode.
preview
Population optimization algorithms: Invasive Weed Optimization (IWO)

Population optimization algorithms: Invasive Weed Optimization (IWO)

The amazing ability of weeds to survive in a wide variety of conditions has become the idea for a powerful optimization algorithm. IWO is one of the best algorithms among the previously reviewed ones.
preview
Understand and efficiently use OpenCL API by recreating built-in support as DLL on Linux (Part 1): Motivation and validation

Understand and efficiently use OpenCL API by recreating built-in support as DLL on Linux (Part 1): Motivation and validation

Bulit-in OpenCL support in MetaTrader 5 still has a major problem especially the one about device selection error 5114 resulting from unable to create an OpenCL context using CL_USE_GPU_ONLY, or CL_USE_GPU_DOUBLE_ONLY although it properly detects GPU. It works fine with directly using of ordinal number of GPU device we found in Journal tab, but that's still considered a bug, and users should not hard-code a device. We will solve it by recreating an OpenCL support as DLL with C++ on Linux. Along the journey, we will get to know OpenCL from concept to best practices in its API usage just enough for us to put into great use later when we deal with DLL implementation in C++ and consume it with MQL5.
preview
Experiments with neural networks (Part 3): Practical application

Experiments with neural networks (Part 3): Practical application

In this article series, I use experimentation and non-standard approaches to develop a profitable trading system and check whether neural networks can be of any help for traders. MetaTrader 5 is approached as a self-sufficient tool for using neural networks in trading.
preview
Creating an EA that works automatically (Part 03): New functions

Creating an EA that works automatically (Part 03): New functions

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. In the previous article, we started to develop an order system that we will use in our automated EA. However, we have created only one of the necessary functions.
preview
Population optimization algorithms: Bat algorithm (BA)

Population optimization algorithms: Bat algorithm (BA)

In this article, I will consider the Bat Algorithm (BA), which shows good convergence on smooth functions.
preview
Creating an EA that works automatically (Part 02): Getting started with the code

Creating an EA that works automatically (Part 02): Getting started with the code

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode. In the previous article, we discussed the first steps that anyone needs to understand before proceeding to creating an Expert Advisor that trades automatically. We considered the concepts and the structure.
preview
Creating an EA that works automatically (Part 01): Concepts and structures

Creating an EA that works automatically (Part 01): Concepts and structures

Today we'll see how to create an Expert Advisor that simply and safely works in automatic mode.
preview
How to choose an Expert Advisor: Twenty strong criteria to reject a trading bot

How to choose an Expert Advisor: Twenty strong criteria to reject a trading bot

This article tries to answer the question: how can we choose the right expert advisors? Which are the best for our portfolio, and how can we filter the large trading bots list available on the market? This article will present twenty clear and strong criteria to reject an expert advisor. Each criterion will be presented and well explained to help you make a more sustained decision and build a more profitable expert advisor collection for your profits.
preview
DoEasy. Controls (Part 31): Scrolling the contents of the ScrollBar control

DoEasy. Controls (Part 31): Scrolling the contents of the ScrollBar control

In this article, I will implement the functionality of scrolling the contents of the container using the buttons of the horizontal scrollbar.
preview
Creating a ticker tape panel: Improved version

Creating a ticker tape panel: Improved version

How do you like the idea of reviving the basic version of our ticker tape panel? The first thing we will do is change the panel to be able to add an image, such as an asset logo or some other image, so that the user could quickly and easily identify the displayed symbol.
preview
Creating a ticker tape panel: Basic version

Creating a ticker tape panel: Basic version

Here I will show how to create screens with price tickers which are usually used to display quotes on the exchange. I will do it by only using MQL5, without using complex external programming.
preview
Population optimization algorithms: Firefly Algorithm (FA)

Population optimization algorithms: Firefly Algorithm (FA)

In this article, I will consider the Firefly Algorithm (FA) optimization method. Thanks to the modification, the algorithm has turned from an outsider into a real rating table leader.