MQL4 and 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
Graphical Interfaces IV: Informational Interface Elements (Chapter 1)
Graphical Interfaces IV: Informational Interface Elements (Chapter 1)

Graphical Interfaces IV: Informational Interface Elements (Chapter 1)

At the current stage of development, the library for creating graphical interfaces contains a form and several controls that can be attached to it. It was mentioned before that one of the future articles would be dedicated to the multi-window mode. Now, we have everything ready for that and we will deal with it in the following chapter. In this chapter, we will write classes for creating the status bar and tooltip informational interface elements.
Developing a cross-platform grider EA (part III): Correction-based grid with martingale
Developing a cross-platform grider EA (part III): Correction-based grid with martingale

Developing a cross-platform grider EA (part III): Correction-based grid with martingale

In this article, we will make an attempt to develop the best possible grid-based EA. As usual, this will be a cross-platform EA capable of working both with MetaTrader 4 and MetaTrader 5. The first EA was good enough, except that it could not make a profit over a long period of time. The second EA could work at intervals of more than several years. Unfortunately, it was unable to yield more than 50% of profit per year with a maximum drawdown of less than 50%.
MQL5 Cookbook: Processing of the TradeTransaction Event
MQL5 Cookbook: Processing of the TradeTransaction Event

MQL5 Cookbook: Processing of the TradeTransaction Event

This article considers capabilities of the MQL5 language from the point of view of the event-driven programming. The greatest advantage of this approach is that the program can receive information about phased implementation of a trade operation. The article also contains an example of receiving and processing information about ongoing trade operation using the TradeTransaction event handler. In my opinion, such an approach can be used for copying deals from one terminal to another.
Program Folder of MetaTrader 4 Client Terminal
Program Folder of MetaTrader 4 Client Terminal

Program Folder of MetaTrader 4 Client Terminal

The article describes the contents of the program folder of MetaTrader 4 Client Terminal. The article will be useful for those who have already started to grasp into the details of the client terminal operation.
MQL5 Cookbook: ОСО Orders
MQL5 Cookbook: ОСО Orders

MQL5 Cookbook: ОСО Orders

Any trader's trading activity involves various mechanisms and interrelationships including relations among orders. This article suggests a solution of OCO orders processing. Standard library classes are extensively involved, as well as new data types are created herein.
preview
DoEasy. Controls (Part 25): Tooltip WinForms object

DoEasy. Controls (Part 25): Tooltip WinForms object

In this article, I will start developing the Tooltip control, as well as new graphical primitives for the library. Naturally, not every element has a tooltip, but every graphical object has the ability to set it.
The Prototype of a Trading Robot
The Prototype of a Trading Robot

The Prototype of a Trading Robot

This article summarizes and systematizes the principles of creating algorithms and elements of trading systems. The article considers designing of expert algorithm. As an example the CExpertAdvisor class is considered, which can be used for quick and easy development of trading systems.
How to Add New UI Languages to the MetaTrader 5 Platform
How to Add New UI Languages to the MetaTrader 5 Platform

How to Add New UI Languages to the MetaTrader 5 Platform

User interface of the MetaTrader 5 platform is translated into several languages. Don't worry if your native language is not among the supported ones. You can easily complete the translation using the special MetaTrader 5 MultiLanguage Pack utility, offered by MetaQuotes Software Corp. for free to all comers. In this article we will show some examples of how to add a new user interface languages to the MetaTrader 5 platform.
Graphical Interfaces VII: The Tabs Control (Chapter 2)
Graphical Interfaces VII: The Tabs Control (Chapter 2)

Graphical Interfaces VII: The Tabs Control (Chapter 2)

The first chapter of seventh part introduced three classes of controls for creating tables: text label table (CLabelsTable), edit box table (CTable) and rendered table (CCanvasTable). In this article (chapter two) we are going to consider the Tabs control.
Testing Performance of Moving Averages Calculation in MQL5
Testing Performance of Moving Averages Calculation in MQL5

Testing Performance of Moving Averages Calculation in MQL5

A number of indicators have appeared since the time of first Moving Average indicator creation. Many of them use the similar smoothing methods, but the performances of different moving averages algorithms have not been studied. In this article, we will consider possible ways of use the Moving Averages in MQL5 and compare their performance.
Econometric Approach to Analysis of Charts
Econometric Approach to Analysis of Charts

Econometric Approach to Analysis of Charts

This article describes the econometric methods of analysis, the autocorrelation analysis and the analysis of conditional variance in particular. What is the benefit of the approach described here? Use of the non-linear GARCH models allows representing the analyzed series formally from the mathematical point of view and creating a forecast for a specified number of steps.
Building a Social Technology Startup, Part II: Programming an MQL5 REST Client
Building a Social Technology Startup, Part II: Programming an MQL5 REST Client

Building a Social Technology Startup, Part II: Programming an MQL5 REST Client

Let's now shape the PHP-based Twitter idea which was introduced in the first part of this article. We are assembling the different parts of the SDSS. Regarding the client side of the system architecture, we are relying on the new MQL5 WebRequest() function for sending trading signals via HTTP.
Three Aspects of Manual Trading Automation. Part 1: Trading
Three Aspects of Manual Trading Automation. Part 1: Trading

Three Aspects of Manual Trading Automation. Part 1: Trading

This article is the first in a series of articles on manual trading automation in the МetaТrader 4 trading platform. Each of the articles will be devoted to one of the following aspects: automation of manual trading, current state of trade display automation and automation of reports on trade results. In this article, I will present an interesting approach to creating EA's controlled manually by a trader.
preview
Brute force approach to pattern search (Part IV): Minimal functionality

Brute force approach to pattern search (Part IV): Minimal functionality

The article presents an improved brute force version, based on the goals set in the previous article. I will try to cover this topic as broadly as possible using Expert Advisors with settings obtained using this method. A new program version is attached to this article.
Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?
Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?

Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?

Everyone starting to work in Forex tries to answer these questions. But not everyone finds the answer, even after many years of hard work and search. I personally have answered this question, as well as many other questions of this article. As a result of these answers a way of creating an efficient trading strategy was determined.
Connecting NeuroSolutions Neuronets
Connecting NeuroSolutions Neuronets

Connecting NeuroSolutions Neuronets

In addition to creation of neuronets, the NeuroSolutions software suite allows exporting them as DLLs. This article describes the process of creating a neuronet, generating a DLL and connecting it to an Expert Advisor for trading in MetaTrader 5.
Library for easy and quick development of MetaTrader programs (part XI). Compatibility with MQL4 - Position closure events
Library for easy and quick development of MetaTrader programs (part XI). Compatibility with MQL4 - Position closure events

Library for easy and quick development of MetaTrader programs (part XI). Compatibility with MQL4 - Position closure events

We continue the development of a large cross-platform library simplifying the development of programs for MetaTrader 5 and MetaTrader 4 platforms. In the tenth part, we resumed our work on the library compatibility with MQL4 and defined the events of opening positions and activating pending orders. In this article, we will define the events of closing positions and get rid of the unused order properties.
Using cloud storage services for data exchange between terminals
Using cloud storage services for data exchange between terminals

Using cloud storage services for data exchange between terminals

Cloud technologies are becoming more popular. Nowadays, we can choose between paid and free storage services. Is it possible to use them in trading? This article proposes a technology for exchanging data between terminals using cloud storage services.
Event handling in MQL5: Changing MA period on-the-fly
Event handling in MQL5: Changing MA period on-the-fly

Event handling in MQL5: Changing MA period on-the-fly

Suppose that simple MA (Moving Average) indicator with period 13 is applied to a chart. And we want to change the period to 20, but we do not want to go to indicator properties dialog box and edit the number 13 to 20: simply tired of these tedious actions with mouse and keyboard. And especially we don't want to open indicator code and modify it. We want to do all this with a single press of a button - "up arrows" next to the numeric keypad. In this article I'll describe how to do it.
Combinatorics and probability for trading (Part IV): Bernoulli Logic
Combinatorics and probability for trading (Part IV): Bernoulli Logic

Combinatorics and probability for trading (Part IV): Bernoulli Logic

In this article, I decided to highlight the well-known Bernoulli scheme and to show how it can be used to describe trading-related data arrays. All this will then be used to create a self-adapting trading system. We will also look for a more generic algorithm, a special case of which is the Bernoulli formula, and will find an application for it.
Self-organizing feature maps (Kohonen maps) - revisiting the subject
Self-organizing feature maps (Kohonen maps) - revisiting the subject

Self-organizing feature maps (Kohonen maps) - revisiting the subject

This article describes techniques of operating with Kohonen maps. The subject will be of interest to both market researchers with basic level of programing in MQL4 and MQL5 and experienced programmers that face difficulties with connecting Kohonen maps to their projects.
Reading RSS News Feeds by Means of MQL4
Reading RSS News Feeds by Means of MQL4

Reading RSS News Feeds by Means of MQL4

This article deals with an example of reading RSS markup by means of MQL4 using the functions for HTML tags analysis. We will try to make a work piece which can then be turned into a news indicator or just an RSS reader on MQL4 language.
MVC design pattern and its possible application
MVC design pattern and its possible application

MVC design pattern and its possible application

The article discusses a popular MVC pattern, as well as the possibilities, pros and cons of its usage in MQL programs. The idea is to split an existing code into three separate components: Model, View and Controller.
Breakpoints in Tester: It's Possible!
Breakpoints in Tester: It's Possible!

Breakpoints in Tester: It's Possible!

The article deals with breakpoint emulation when passed through Tester, debug information being displayed.
Indicator Taichi - a Simple Idea of Formalizing the Values of Ichimoku Kinko Hyo
Indicator Taichi - a Simple Idea of Formalizing the Values of Ichimoku Kinko Hyo

Indicator Taichi - a Simple Idea of Formalizing the Values of Ichimoku Kinko Hyo

Hard to interpret Ichimoku signals? This article introduces some principles of formalizing values and signals of Ichimoku Kinko Hyo. For visualization of its usage the author chose the currency pair EURUSD based on his own preferences. However, the indicator can be used on any currency pair.
MQL5 Cookbook: Position Properties on the Custom Info Panel
MQL5 Cookbook: Position Properties on the Custom Info Panel

MQL5 Cookbook: Position Properties on the Custom Info Panel

This time we will create a simple Expert Advisor that will get position properties on the current symbol and display them on the custom info panel during manual trading. The info panel will be created using graphical objects and displayed information will be refreshed at every tick. This is going to be much more convenient than all the time having to manually run the script described in the previous article of the series called "MQL5 Cookbook: Getting Position Properties".
Interview with Alexey Masterov (ATC 2012)
Interview with Alexey Masterov (ATC 2012)

Interview with Alexey Masterov (ATC 2012)

We do our best to introduce all the leading Championship Participants to our audience in reasonable time. To achieve that, we closely monitor the most promising contestants in our TOP-10 and arrange interviews with them. However, the sharp rise of Alexey Masterov (reinhard) up to the third place has become a real surprise!
Statistical Probability Distributions in MQL5
Statistical Probability Distributions in MQL5

Statistical Probability Distributions in MQL5

The article addresses probability distributions (normal, log-normal, binomial, logistic, exponential, Cauchy distribution, Student's t-distribution, Laplace distribution, Poisson distribution, Hyperbolic Secant distribution, Beta and Gamma distribution) of random variables used in Applied Statistics. It also features classes for handling these distributions.
Drawing Dial Gauges Using the CCanvas Class
Drawing Dial Gauges Using the CCanvas Class

Drawing Dial Gauges Using the CCanvas Class

We can find dial gauges in cars and airplanes, in industrial production and everyday life. They are used in all spheres which require quick response to behavior of a controlled value. This article describes the library of dial gauges for MetaTrader 5.
Other classes in DoEasy library (Part 66): MQL5.com Signals collection class
Other classes in DoEasy library (Part 66): MQL5.com Signals collection class

Other classes in DoEasy library (Part 66): MQL5.com Signals collection class

In this article, I will create the signal collection class of the MQL5.com Signals service with the functions for managing signals. Besides, I will improve the Depth of Market snapshot object class for displaying the total DOM buy and sell volumes.
Video: Simple automated trading – How to create a simple Expert Advisor with MQL5
Video: Simple automated trading – How to create a simple Expert Advisor with MQL5

Video: Simple automated trading – How to create a simple Expert Advisor with MQL5

The majority of students in my courses felt that MQL5 was really difficult to understand. In addition to this, they were searching for a straightforward method to automate a few processes. Find out how to begin working with MQL5 right now by reading the information contained in this article. Even if you have never done any form of programming before. And even in the event that you are unable to comprehend the previous illustrations that you have observed.
MQL5 Wizard: How to Create a Module of Trailing of Open Positions
MQL5 Wizard: How to Create a Module of Trailing of Open Positions

MQL5 Wizard: How to Create a Module of Trailing of Open Positions

The generator of trade strategies MQL5 Wizard greatly simplifies the testing of trading ideas. The article discusses how to write and connect to the generator of trade strategies MQL5 Wizard your own class of managing open positions by moving the Stop Loss level to a lossless zone when the price goes in the position direction, allowing to protect your profit decrease drawdowns when trading. It also tells about the structure and format of the description of the created class for the MQL5 Wizard.
Separate optimization of a strategy on trend and flat conditions
Separate optimization of a strategy on trend and flat conditions

Separate optimization of a strategy on trend and flat conditions

The article considers applying the separate optimization method during various market conditions. Separate optimization means defining trading system's optimal parameters by optimizing for an uptrend and downtrend separately. To reduce the effect of false signals and improve profitability, the systems are made flexible, meaning they have some specific set of settings or input data, which is justified because the market behavior is constantly changing.
Pivot Points Helping to Define Market Trends
Pivot Points Helping to Define Market Trends

Pivot Points Helping to Define Market Trends

Pivot point is a line in the price chart that shows the further trend of a currency pair. If the price is above this line, it tends to grow. If the price is below this line, accordingly, it tends to fall.
How to Prepare MetaTrader 5 Quotes for Other Applications
How to Prepare MetaTrader 5 Quotes for Other Applications

How to Prepare MetaTrader 5 Quotes for Other Applications

The article describes the examples of creating directories, copying data, filing, working with the symbols in Market Watch or the common list, as well as the examples of handling errors, etc. All these elements can eventually be gathered in a single script for filing the data in a user-defined format.
Research of Statistical Recurrences of Candle Directions
Research of Statistical Recurrences of Candle Directions

Research of Statistical Recurrences of Candle Directions

Is it possible to predict the behavior of the market for a short upcoming interval of time, based on the recurring tendencies of candle directions, at specific times throughout the day? That is, If such an occurrence is found in the first place. This question has probably arisen in the mind of every trader. The purpose of this article is to attempt to predict the behavior of the market, based on the statistical recurrences of candle directions during specific intervals of time.
preview
Learn how to design a trading system by Relative Vigor Index

Learn how to design a trading system by Relative Vigor Index

A new article in our series about how to design a trading system by the most popular technical indicator. In this article, we will learn how to do that by the Relative Vigor Index indicator.
Technical Indicators and Digital Filters
Technical Indicators and Digital Filters

Technical Indicators and Digital Filters

In this article, technical indicators are treated as digital filters. Operation principles and basic characteristics of digital filters are explained. Also, some practical ways of receiving the filter kernel in MetaTrader 5 terminal and integration with a ready-made spectrum analyzer proposed in the article "Building a Spectrum Analyzer" are considered. Pulse and spectrum characteristics of the typical digital filters are used as examples.
Graphics in DoEasy library (Part 78): Animation principles in the library. Image slicing
Graphics in DoEasy library (Part 78): Animation principles in the library. Image slicing

Graphics in DoEasy library (Part 78): Animation principles in the library. Image slicing

In this article, I will define the animation principles to be used in some parts of the library. I will also develop a class for copying a part of the image and pasting it to a specified form object location while preserving and restoring the part of the form background the image is to be superimposed on.
Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)
Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)

Graphical Interfaces II: the Separation Line and Context Menu Elements (Chapter 2)

In this article we will create the separation line element. It will be possible to use it not only as an independent interface element but also as a part of many other elements. After that, we will have everything required for the development of the context menu class, which will be also considered in this article in detail. Added to that, we will introduce all necessary additions to the class, which is the base for storing pointers to all the elements of the graphical interface of the application.