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
MQL5 Wizard techniques you should know (Part 01): Regression Analysis

MQL5 Wizard techniques you should know (Part 01): Regression Analysis

Todays trader is a philomath who is almost always (either consciously or not...) looking up new ideas, trying them out, choosing to modify them or discard them; an exploratory process that should cost a fair amount of diligence. This clearly places a premium on the trader's time and the need to avoid mistakes. These series of articles will proposition that the MQL5 wizard should be a mainstay for traders. Why? Because not only does the trader save time by assembling his new ideas with the MQL5 wizard, and greatly reduce mistakes from duplicate coding; he is ultimately set-up to channel his energy on the few critical areas of his trading philosophy.
preview
Creating an EA that works automatically (Part 09): Automation (I)

Creating an EA that works automatically (Part 09): Automation (I)

Although the creation of an automated EA is not a very difficult task, however, many mistakes can be made without the necessary knowledge. In this article, we will look at how to build the first level of automation, which consists in creating a trigger to activate breakeven and a trailing stop level.
preview
Creating Graphical Panels Became Easy in MQL5

Creating Graphical Panels Became Easy in MQL5

In this article, we will provide a simple and easy guide to anyone who needs to create one of the most valuable and helpful tools in trading which is the graphical panel to simplify and ease doing tasks around trading which helps to save time and focus more on your trading process itself without any distractions.
Technical Analysis: How Do We Analyze?
Technical Analysis: How Do We Analyze?

Technical Analysis: How Do We Analyze?

This article briefly describes the author's opinion on redrawing indicators, multi-timeframe indicators and displaying of quotes with Japanese candlesticks. The article contain no programming specifics and is of a general character.
preview
Gain An Edge Over Any Market

Gain An Edge Over Any Market

Learn how you can get ahead of any market you wish to trade, regardless of your current level of skill.
Electronic Tables in MQL5
Electronic Tables in MQL5

Electronic Tables in MQL5

The article describes a class of dynamic two-dimensional array that contains data of different types in its first dimension. Storing data in the form of a table is convenient for solving a wide range of problems of arrangement, storing and operation with bound information of different types. The source code of the class that implements the functionality of working with tables is attached to the article.
MQL5 Cookbook: Handling Custom Chart Events
MQL5 Cookbook: Handling Custom Chart Events

MQL5 Cookbook: Handling Custom Chart Events

This article considers aspects of design and development of custom chart events system in the MQL5 environment. An example of an approach to the events classification can also be found here, as well as a program code for a class of events and a class of custom events handler.
Prices in DoEasy library (part 59): Object to store data of one tick
Prices in DoEasy library (part 59): Object to store data of one tick

Prices in DoEasy library (part 59): Object to store data of one tick

From this article on, start creating library functionality to work with price data. Today, create an object class which will store all price data which arrived with yet another tick.
Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!
Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!

Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!

MQL5 provides programmers with a very complete set of functions and object-oriented API thanks to which they can do everything they want within the MetaTrader environment. However, Web Technology is an extremely versatile tool nowadays that may come to the rescue in some situations when you need to do something very specific, want to marvel your customers with something different or simply you do not have enough time to master a specific part of MT5 Standard Library. Today's exercise walks you through a practical example about how you can manage your development time at the same time as you also create an amazing tech cocktail.
preview
Creating an EA that works automatically (Part 13): Automation (V)

Creating an EA that works automatically (Part 13): Automation (V)

Do you know what a flowchart is? Can you use it? Do you think flowcharts are for beginners? I suggest that we proceed to this new article and learn how to work with flowcharts.
preview
Understanding functions in MQL5 with applications

Understanding functions in MQL5 with applications

Functions are critical things in any programming language, it helps developers apply the concept of (DRY) which means do not repeat yourself, and many other benefits. In this article, you will find much more information about functions and how we can create our own functions in MQL5 with simple applications that can be used or called in any system you have to enrich your trading system without complicating things.
preview
Developing a trading Expert Advisor from scratch (Part 8): A conceptual leap

Developing a trading Expert Advisor from scratch (Part 8): A conceptual leap

What is the easiest way to implement new functionality? In this article, we will take one step back and then two steps forward.
preview
Rebuy algorithm: Math model for increasing efficiency

Rebuy algorithm: Math model for increasing efficiency

In this article, we will use the rebuy algorithm for a deeper understanding of the efficiency of trading systems and start working on the general principles of improving trading efficiency using mathematics and logic, as well as apply the most non-standard methods of increasing efficiency in terms of using absolutely any trading system.
preview
MQL5 Wizard techniques you should know (Part 02): Kohonen Maps

MQL5 Wizard techniques you should know (Part 02): Kohonen Maps

These series of articles will proposition that the MQL5 Wizard should be a mainstay for traders. Why? Because not only does the trader save time by assembling his new ideas with the MQL5 Wizard, and greatly reduce mistakes from duplicate coding; he is ultimately set-up to channel his energy on the few critical areas of his trading philosophy.
preview
Develop a Proof-of-Concept DLL with C++ multi-threading support for MetaTrader 5 on Linux

Develop a Proof-of-Concept DLL with C++ multi-threading support for MetaTrader 5 on Linux

We will begin the journey to explore the steps and workflow on how to base development for MetaTrader 5 platform solely on Linux system in which the final product works seamlessly on both Windows and Linux system. We will get to know Wine, and Mingw; both are the essential tools to make cross-platform development works. Especially Mingw for its threading implementations (POSIX, and Win32) that we need to consider in choosing which one to go with. We then build a proof-of-concept DLL and consume it in MQL5 code, finally compare the performance of both threading implementations. All for your foundation to expand further on your own. You should be comfortable building MT related tools on Linux after reading this article.
preview
MQL5 — You too can become a master of this language

MQL5 — You too can become a master of this language

This article will be a kind of interview with myself, in which I will tell you how I took my first steps in the MQL5 language. I will show you how you can become a great MQL5 programmer. I will explain the necessary bases for you to achieve this feat. The only prerequisite is a willingness to learn.
preview
The price movement model and its main provisions (Part 2): Probabilistic price field evolution equation and the occurrence of the observed random walk

The price movement model and its main provisions (Part 2): Probabilistic price field evolution equation and the occurrence of the observed random walk

The article considers the probabilistic price field evolution equation and the upcoming price spike criterion. It also reveals the essence of price values on charts and the mechanism for the occurrence of a random walk of these values.
preview
Developing a Replay System — Market simulation (Part 01): First experiments (I)

Developing a Replay System — Market simulation (Part 01): First experiments (I)

How about creating a system that would allow us to study the market when it is closed or even to simulate market situations? Here we are going to start a new series of articles in which we will deal with this topic.
New Opportunities with MetaTrader 5
New Opportunities with MetaTrader 5

New Opportunities with MetaTrader 5

MetaTrader 4 gained its popularity with traders from all over the world, and it seemed like nothing more could be wished for. With its high processing speed, stability, wide array of possibilities for writing indicators, Expert Advisors, and informatory-trading systems, and the ability to chose from over a hundred different brokers, - the terminal greatly distinguished itself from the rest. But time doesn’t stand still, and we find ourselves facing a choice of MetaTrade 4 or MetaTrade 5. In this article, we will describe the main differences of the 5th generation terminal from our current favor.
preview
Graphics in DoEasy library (Part 97): Independent handling of form object movement

Graphics in DoEasy library (Part 97): Independent handling of form object movement

In this article, I will consider the implementation of the independent dragging of any form objects using a mouse. Besides, I will complement the library by error messages and new deal properties previously implemented into the terminal and MQL5.
preview
Category Theory in MQL5 (Part 14): Functors with Linear-Orders

Category Theory in MQL5 (Part 14): Functors with Linear-Orders

This article which is part of a broader series on Category Theory implementation in MQL5, delves into Functors. We examine how a Linear Order can be mapped to a set, thanks to Functors; by considering two sets of data that one would typically dismiss as having any connection.
preview
Timeseries in DoEasy library (part 54): Descendant classes of abstract base indicator

Timeseries in DoEasy library (part 54): Descendant classes of abstract base indicator

The article considers creation of classes of descendant objects of base abstract indicator. Such objects will provide access to features of creating indicator EAs, collecting and getting data value statistics of various indicators and prices. Also, create indicator object collection from which getting access to properties and data of each indicator created in the program will be possible.
preview
Neural networks made easy (Part 24): Improving the tool for Transfer Learning

Neural networks made easy (Part 24): Improving the tool for Transfer Learning

In the previous article, we created a tool for creating and editing the architecture of neural networks. Today we will continue working on this tool. We will try to make it more user friendly. This may see, top be a step away form our topic. But don't you think that a well organized workspace plays an important role in achieving the result.
Using Assertions in MQL5 Programs
Using Assertions in MQL5 Programs

Using Assertions in MQL5 Programs

This article covers the use of assertions in MQL5 language. It provides two examples of the assertion mechanism and some general guidance for implementing assertions.
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
Trading strategy based on the improved Doji candlestick pattern recognition indicator

Trading strategy based on the improved Doji candlestick pattern recognition indicator

The metabar-based indicator detected more candles than the conventional one. Let's check if this provides real benefit in the automated trading.
preview
Multiple indicators on one chart (Part 02): First experiments

Multiple indicators on one chart (Part 02): First experiments

In the previous article "Multiple indicators on one chart" I presented the concept and the basics of how to use multiple indicators on one chart. In this article, I will provide the source code and will explain it in detail.
preview
Developing a Replay System — Market simulation (Part 02): First experiments (II)

Developing a Replay System — Market simulation (Part 02): First experiments (II)

This time, let's try a different approach to achieve the 1 minute goal. However, this task is not as simple as one might think.
preview
How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 5):  Bollinger Bands On Keltner Channel — Indicators Signal

How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 5): Bollinger Bands On Keltner Channel — Indicators Signal

The Multi-Currency Expert Advisor in this article is an Expert Advisor or Trading Robot that can trade (open orders, close orders and manage orders for example: Trailing Stop Loss and Trailing Profit) for more than one symbol pair from only one symbol chart. In this article we will use signals from two indicators, in this case Bollinger Bands® on Keltner Channel.
Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"
Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"

Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"

A programmer from Krasnoyarsk Nikolay Ivanov (Techno) is a leader among the developers in terms of the number of completed orders - he has implemented already more than 200 applications in the Jobs service. In this interview, he is talking about the Jobs service, its specific features and challengers faced by programmers.
Technical Analysis: What Do We Analyze?
Technical Analysis: What Do We Analyze?

Technical Analysis: What Do We Analyze?

This article tries to analyze several peculiarities of representation of quotes available in the MetaTrader client terminal. The article is general, it doesn't concern programming.
preview
DoEasy. Controls (Part 13): Optimizing interaction of WinForms objects with the mouse, starting the development of the TabControl WinForms object

DoEasy. Controls (Part 13): Optimizing interaction of WinForms objects with the mouse, starting the development of the TabControl WinForms object

In this article, I will fix and optimize handling the appearance of WinForms objects after moving the mouse cursor away from the object, as well as start the development of the TabControl WinForms object.
preview
Algorithmic Trading With MetaTrader 5 And R For Beginners

Algorithmic Trading With MetaTrader 5 And R For Beginners

Embark on a compelling exploration where financial analysis meets algorithmic trading as we unravel the art of seamlessly uniting R and MetaTrader 5. This article is your guide to bridging the realms of analytical finesse in R with the formidable trading capabilities of MetaTrader 5.
Graphics in DoEasy library (Part 90): Standard graphical object events. Basic functionality
Graphics in DoEasy library (Part 90): Standard graphical object events. Basic functionality

Graphics in DoEasy library (Part 90): Standard graphical object events. Basic functionality

In this article, I will implement the basic functionality for tracking standard graphical object events. I will start from a double click event on a graphical object.
preview
Category Theory in MQL5 (Part 1)

Category Theory in MQL5 (Part 1)

Category Theory is a diverse and expanding branch of Mathematics which as of yet is relatively uncovered in the MQL 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
MQL5 Wizard techniques you should know (Part 05): Markov Chains

MQL5 Wizard techniques you should know (Part 05): Markov Chains

Markov chains are a powerful mathematical tool that can be used to model and forecast time series data in various fields, including finance. In financial time series modelling and forecasting, Markov chains are often used to model the evolution of financial assets over time, such as stock prices or exchange rates. One of the main advantages of Markov chain models is their simplicity and ease of use.
Timeseries in DoEasy library (part 48): Multi-period multi-symbol indicators on one buffer in a subwindow
Timeseries in DoEasy library (part 48): Multi-period multi-symbol indicators on one buffer in a subwindow

Timeseries in DoEasy library (part 48): Multi-period multi-symbol indicators on one buffer in a subwindow

The article considers an example of creating multi-symbol multi-period standard indicators using a single indicator buffer for construction and working in the indicator subwindow. I am going to prepare the library classes for working with standard indicators working in the program main window and having more than one buffer for displaying their data.
preview
Developing a trading Expert Advisor from scratch (Part 22): New order system (V)

Developing a trading Expert Advisor from scratch (Part 22): New order system (V)

Today we will continue to develop the new order system. It is not that easy to implement a new system as we often encounter problems which greatly complicate the process. When these problems appear, we have to stop and re-analyze the direction in which we are moving.
preview
Advanced resampling and selection of CatBoost models by brute-force method

Advanced resampling and selection of CatBoost models by brute-force method

This article describes one of the possible approaches to data transformation aimed at improving the generalizability of the model, and also discusses sampling and selection of CatBoost models.
Better Programmer (Part 03): Give Up doing these 5 things to become a successful MQL5 Programmer
Better Programmer (Part 03): Give Up doing these 5 things to become a successful MQL5 Programmer

Better Programmer (Part 03): Give Up doing these 5 things to become a successful MQL5 Programmer

This is the must-read article for anyone wanting to improve their programming career. This article series is aimed at making you the best programmer you can possibly be, no matter how experienced you are. The discussed ideas work for MQL5 programming newbies as well as professionals.