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
Neural networks made easy (Part 66): Exploration problems in offline learning

Neural networks made easy (Part 66): Exploration problems in offline learning

Models are trained offline using data from a prepared training dataset. While providing certain advantages, its negative side is that information about the environment is greatly compressed to the size of the training dataset. Which, in turn, limits the possibilities of exploration. In this article, we will consider a method that enables the filling of a training dataset with the most diverse data possible.
Interview with Tim Fass (ATC 2011)
Interview with Tim Fass (ATC 2011)

Interview with Tim Fass (ATC 2011)

A student from Germany Tim Fass (Tim) is participating in the Automated Trading Championship for the first time. Nevertheless, his Expert Advisor The_Wild_13 already got featured at the very top of the Championship rating and seems to be holding his position in the top ten. Tim told us about his Expert Advisor, his faith in the success of simple strategies and his wildest dreams.
Do Traders Need Services From Developers?
Do Traders Need Services From Developers?

Do Traders Need Services From Developers?

Algorithmic trading becomes more popular and needed, which naturally led to a demand for exotic algorithms and unusual tasks. To some extent, such complex applications are available in the Code Base or in the Market. Although traders have simple access to those apps in a couple of clicks, these apps may not satisfy all needs in full. In this case, traders look for developers who can write a desired application in the MQL5 Freelance section and assign an order.
preview
Design Patterns in software development and MQL5 (Part I): Creational Patterns

Design Patterns in software development and MQL5 (Part I): Creational Patterns

There are methods that can be used to solve many problems that can be repeated. Once understand how to use these methods it can be very helpful to create your software effectively and apply the concept of DRY ((Do not Repeat Yourself). In this context, the topic of Design Patterns will serve very well because they are patterns that provide solutions to well-described and repeated problems.
Alexander Anufrenko: "A danger foreseen is half avoided" (ATC 2010)
Alexander Anufrenko: "A danger foreseen is half avoided" (ATC 2010)

Alexander Anufrenko: "A danger foreseen is half avoided" (ATC 2010)

The risky development of Alexander Anufrenko (Anufrenko321) had been featured among the top three of the Championship for three weeks. Having suffered a catastrophic Stop Loss last week, his Expert Advisor lost about $60,000, but now once again he is approaching the leaders. In this interview the author of this interesting EA is describing the operating principles and characteristics of his application.
Interview with Andrea Zani (ATC 2011)
Interview with Andrea Zani (ATC 2011)

Interview with Andrea Zani (ATC 2011)

On the eleventh week of the Automated Trading Championship, Andrea Zani (sbraer) got featured very close to the top five of the competition. It is on the sixth place with about 47,000 USD now. Andrea's Expert Advisor AZXY has made only one losing deal, which was at the very beginning of the Championship. Since then, its equity curve has been steadily growing.
preview
Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators

Ready-made templates for including indicators to Expert Advisors (Part 1): Oscillators

The article considers standard indicators from the oscillator category. We will create ready-to-use templates for their use in EAs - declaring and setting parameters, indicator initialization and deinitialization, as well as receiving data and signals from indicator buffers in EAs.
preview
DoEasy. Controls (Part 5): Base WinForms object, Panel control, AutoSize parameter

DoEasy. Controls (Part 5): Base WinForms object, Panel control, AutoSize parameter

In the article, I will create the base object of all library WinForms objects and start implementing the AutoSize property of the Panel WinForms object — auto sizing for fitting the object internal content.
Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"
Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"

Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"

Andrey Bolkonsky (abolk) has been participating in the Jobs service since its opening. He has developed dozens of indicators and Expert Advisors for the MetaTrader 4 and MetaTrader 5 platforms. We will talk with Andrey about what a server is from the perspective of a programmer.
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.
preview
Developing an MQL5 RL agent with RestAPI integration (Part 2): MQL5 functions for HTTP interaction with the tic-tac-toe game REST API

Developing an MQL5 RL agent with RestAPI integration (Part 2): MQL5 functions for HTTP interaction with the tic-tac-toe game REST API

In this article we will talk about how MQL5 can interact with Python and FastAPI, using HTTP calls in MQL5 to interact with the tic-tac-toe game in Python. The article discusses the creation of an API using FastAPI for this integration and provides a test script in MQL5, highlighting the versatility of MQL5, the simplicity of Python, and the effectiveness of FastAPI in connecting different technologies to create innovative solutions.
preview
Developing an MQTT client for MetaTrader 5: a TDD approach — Part 3

Developing an MQTT client for MetaTrader 5: a TDD approach — Part 3

This article is the third part of a series describing our development steps of a native MQL5 client for the MQTT protocol. In this part, we describe in detail how we are using Test-Driven Development to implement the Operational Behavior part of the CONNECT/CONNACK packet exchange. At the end of this step, our client MUST be able to behave appropriately when dealing with any of the possible server outcomes from a connection attempt.
Dimitar Manov: "I fear only extraordinary situations in the Championship" (ATC 2010)
Dimitar Manov: "I fear only extraordinary situations in the Championship" (ATC 2010)

Dimitar Manov: "I fear only extraordinary situations in the Championship" (ATC 2010)

In the recent review by Boris Odintsov the Expert Advisor of the Bulgarian Participant Dimitar Manov appeared among the most stable and reliable EAs. We decided to interview this developer and try to find the secret of his success. In this interview Dimitar has told us what situation would be unfavorable for his robot, why he's not using indicators and whether he is expecting to win the competition.
preview
Population optimization algorithms: Cuckoo Optimization Algorithm (COA)

Population optimization algorithms: Cuckoo Optimization Algorithm (COA)

The next algorithm I will consider is cuckoo search optimization using Levy flights. This is one of the latest optimization algorithms and a new leader in the leaderboard.
preview
Category Theory in MQL5 (Part 20): A detour to Self-Attention and the Transformer

Category Theory in MQL5 (Part 20): A detour to Self-Attention and the Transformer

We digress in our series by pondering at part of the algorithm to chatGPT. Are there any similarities or concepts borrowed from natural transformations? We attempt to answer these and other questions in a fun piece, with our code in a signal class format.
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
Developing a Replay System (Part 27): Expert Advisor project — C_Mouse class (I)

Developing a Replay System (Part 27): Expert Advisor project — C_Mouse class (I)

In this article we will implement the C_Mouse class. It provides the ability to program at the highest level. However, talking about high-level or low-level programming languages is not about including obscene words or jargon in the code. It's the other way around. When we talk about high-level or low-level programming, we mean how easy or difficult the code is for other programmers to understand.
preview
Understand and Efficiently use OpenCL API by Recreating built-in support as DLL on Linux (Part 2): OpenCL Simple DLL implementation

Understand and Efficiently use OpenCL API by Recreating built-in support as DLL on Linux (Part 2): OpenCL Simple DLL implementation

Continued from the part 1 in the series, now we proceed to implement as a simple DLL then test with MetaTrader 5. This will prepare us well before developing a full-fledge OpenCL as DLL support in the following part to come.
preview
Population optimization algorithms: Saplings Sowing and Growing up (SSG)

Population optimization algorithms: Saplings Sowing and Growing up (SSG)

Saplings Sowing and Growing up (SSG) algorithm is inspired by one of the most resilient organisms on the planet demonstrating outstanding capability for survival in a wide variety of conditions.
preview
Experiments with neural networks (Part 4): Templates

Experiments with neural networks (Part 4): Templates

In this article, I will 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 as a self-sufficient tool for using neural networks in trading. Simple explanation.
preview
DoEasy. Controls (Part 24): Hint auxiliary WinForms object

DoEasy. Controls (Part 24): Hint auxiliary WinForms object

In this article, I will revise the logic of specifying the base and main objects for all WinForms library objects, develop a new Hint base object and several of its derived classes to indicate the possible direction of moving the separator.
Interview with Valery Mazurenko (ATC 2011)
Interview with Valery Mazurenko (ATC 2011)

Interview with Valery Mazurenko (ATC 2011)

The task of writing an Expert Advisor trading on multiple currency pairs is complex both in terms of finding suitable strategies and from the technological side. But if the goal is set clear, nothing is impossible then. It was four times already that Vitaly Mazurenko (notused) submitted his multi-currency Expert Advisor. It seems, he has managed to find the right way this time.
preview
Category Theory in MQL5 (Part 18): Naturality Square

Category Theory in MQL5 (Part 18): Naturality Square

This article continues our series into category theory by introducing natural transformations, a key pillar within the subject. We look at the seemingly complex definition, then delve into examples and applications with this series’ ‘bread and butter’; volatility forecasting.
Interview with Berron Parker (ATC 2010)
Interview with Berron Parker (ATC 2010)

Interview with Berron Parker (ATC 2010)

During the first week of the Championship Berron's Expert Advisor has been on the top position. He now tells us about his experience of EA development and difficulties of moving to MQL5. Berron says his EA is set up to work in a trend market, but can be weak in other market conditions. However, he is hopeful that his robot will show good results in this competition.
Interview with Igor Korepin (ATC 2011)
Interview with Igor Korepin (ATC 2011)

Interview with Igor Korepin (ATC 2011)

Appearance of the Expert Advisor cs2011 by Igor Korepin (Xupypr) at the very top of the Automated Trading Championship 2011 was really impressive - its balance was almost twice that of the EA featured on the second place. However, despite such a sound breakaway, the Expert Advisor could not stay long on the first line. Igor frankly said that he relied much on a lucky start of his trading robot in the competition. We'll see if luck helps this simple EA to take the lead in the ATC 2011 race again.
preview
Category Theory in MQL5 (Part 2)

Category Theory in MQL5 (Part 2)

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 attracts comments and discussion while hopefully furthering the use of this remarkable field in Traders' strategy development.
preview
Neural networks made easy (Part 48): Methods for reducing overestimation of Q-function values

Neural networks made easy (Part 48): Methods for reducing overestimation of Q-function values

In the previous article, we introduced the DDPG method, which allows training models in a continuous action space. However, like other Q-learning methods, DDPG is prone to overestimating Q-function values. This problem often results in training an agent with a suboptimal strategy. In this article, we will look at some approaches to overcome the mentioned issue.
Interview with Boris Odintsov (ATC 2010)
Interview with Boris Odintsov (ATC 2010)

Interview with Boris Odintsov (ATC 2010)

Boris Odintsov is one of the most impressive participants of the Championship who managed to go beyond $100,000 on the third week of the competition. Boris explains the rapid rise of his expert Advisor as a favorable combination of circumstances. In this interview he tells about what is important in trading, and what market would be unfavorable for his EA.
preview
Multilayer perceptron and backpropagation algorithm (Part 3): Integration with the Strategy Tester - Overview (I).

Multilayer perceptron and backpropagation algorithm (Part 3): Integration with the Strategy Tester - Overview (I).

The multilayer perceptron is an evolution of the simple perceptron which can solve non-linear separable problems. Together with the backpropagation algorithm, this neural network can be effectively trained. In Part 3 of the Multilayer Perceptron and Backpropagation series, we'll see how to integrate this technique into the Strategy Tester. This integration will allow the use of complex data analysis aimed at making better decisions to optimize your trading strategies. In this article, we will discuss the advantages and problems of this technique.
Interview with Andrey Bobryashov (ATC 2011)
Interview with Andrey Bobryashov (ATC 2011)

Interview with Andrey Bobryashov (ATC 2011)

Since the first Automated Trading Championship we have seen plenty of trading robots in our TOP-10 created with the use of various methods. Excellent results were shown both by the Exper Advisors based on standard indicators, and complicated analytical complexes with weekly automatic optimization of their own parameters.
preview
Integrate Your Own LLM into EA (Part 2): Example of Environment Deployment

Integrate Your Own LLM into EA (Part 2): Example of Environment Deployment

With the rapid development of artificial intelligence today, language models (LLMs) are an important part of artificial intelligence, so we should think about how to integrate powerful LLMs into our algorithmic trading. For most people, it is difficult to fine-tune these powerful models according to their needs, deploy them locally, and then apply them to algorithmic trading. This series of articles will take a step-by-step approach to achieve this goal.
preview
Brute force approach to patterns search (Part V): Fresh angle

Brute force approach to patterns search (Part V): Fresh angle

In this article, I will show a completely different approach to algorithmic trading I ended up with after quite a long time. Of course, all this has to do with my brute force program, which has undergone a number of changes that allow it to solve several problems simultaneously. Nevertheless, the article has turned out to be more general and as simple as possible, which is why it is also suitable for those who know nothing about brute force.
Interview with Antonio Morillas (ATC 2011)
Interview with Antonio Morillas (ATC 2011)

Interview with Antonio Morillas (ATC 2011)

Antonio Morillas from Spain (sallirom, by the way - it is reversed surname!) was first who doubled his starting balance from the beginning of the Championship and thus attracted our attention. His trading strategy is extremely risky. We decided to talk to Antonio about risk and luck as these are part and parcel of Automated Trading Championship.
preview
Python, ONNX and MetaTrader 5: Creating a RandomForest model with RobustScaler and PolynomialFeatures data preprocessing

Python, ONNX and MetaTrader 5: Creating a RandomForest model with RobustScaler and PolynomialFeatures data preprocessing

In this article, we will create a random forest model in Python, train the model, and save it as an ONNX pipeline with data preprocessing. After that we will use the model in the MetaTrader 5 terminal.
Interview with Vitaly Antonov (ATC 2011)
Interview with Vitaly Antonov (ATC 2011)

Interview with Vitaly Antonov (ATC 2011)

It was only this summer that Vitaly Antonov (beast) has learned about the upcoming Automated Trading Championship and got to know MetaTrader 5 terminal. Time was running out, besides, Vitaly was a newcomer. So, he randomly chose GBPUSD currency pair to develop his trading system. And the choice turned out to be successful. It would have been impossible to use other symbols with the strategy.
preview
Integrating ML models with the Strategy Tester (Part 3): Managing CSV files (II)

Integrating ML models with the Strategy Tester (Part 3): Managing CSV files (II)

This material provides a complete guide to creating a class in MQL5 for efficient management of CSV files. We will see the implementation of methods for opening, writing, reading, and transforming data. We will also consider how to use them to store and access information. In addition, we will discuss the limitations and the most important aspects of using such a class. This article ca be a valuable resource for those who want to learn how to process CSV files in MQL5.
preview
How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 7): ZigZag with Awesome Oscillator Indicators Signal

How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 7): ZigZag with Awesome Oscillator Indicators Signal

The multi-currency expert advisor in this article is an expert advisor or automated trading that uses ZigZag indicator which are filtered with the Awesome Oscillator or filter each other's signals.
ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)
ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)

ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)

This is the first interview in the "ATC Champions League" project. Roman Zamozhniy (Rich) from Ukraine was the winner of the first Automated Trading Championship in 2006. In addition, he is a regular participant of our Championships - he has not missed a single contest. In this interview, we talked about Roman's first place and tried to figure out what is necessary for successful participation.
preview
DoEasy. Controls (Part 28): Bar styles in the ProgressBar control

DoEasy. Controls (Part 28): Bar styles in the ProgressBar control

In this article, I will develop display styles and description text for the progress bar of the ProgressBar control.
preview
Data Science and Machine Learning (Part 19): Supercharge Your AI models with AdaBoost

Data Science and Machine Learning (Part 19): Supercharge Your AI models with AdaBoost

AdaBoost, a powerful boosting algorithm designed to elevate the performance of your AI models. AdaBoost, short for Adaptive Boosting, is a sophisticated ensemble learning technique that seamlessly integrates weak learners, enhancing their collective predictive strength.