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
Practical application of neural networks in trading
Practical application of neural networks in trading

Practical application of neural networks in trading

In this article, we will consider the main aspects of integration of neural networks and the trading terminal, with the purpose of creating a fully featured trading robot.
Manual charting and trading toolkit (Part I). Preparation: structure description and helper class
Manual charting and trading toolkit (Part I). Preparation: structure description and helper class

Manual charting and trading toolkit (Part I). Preparation: structure description and helper class

This is the first article in a series, in which I am going to describe a toolkit which enables manual application of chart graphics by utilizing keyboard shortcuts. It is very convenient: you press one key and a trendline appears, you press another key — this will create a Fibonacci fan with the necessary parameters. It will also be possible to switch timeframes, to rearrange layers or to delete all objects from the chart.
Timeseries in DoEasy library (part 44): Collection class of indicator buffer objects
Timeseries in DoEasy library (part 44): Collection class of indicator buffer objects

Timeseries in DoEasy library (part 44): Collection class of indicator buffer objects

The article deals with creating a collection class of indicator buffer objects. I am going to test the ability to create and work with any number of buffers for indicators (the maximum number of buffers that can be created in MQL indicators is 512).
MQL as a Markup Tool for the Graphical Interface of MQL Programs (Part 3). Form Designer
MQL as a Markup Tool for the Graphical Interface of MQL Programs (Part 3). Form Designer

MQL as a Markup Tool for the Graphical Interface of MQL Programs (Part 3). Form Designer

In this paper, we are completing the description of our concept of building the window interface of MQL programs, using the structures of MQL. Specialized graphical editor will allow to interactively set up the layout that consists of the basic classes of the GUI elements and then export it into the MQL description to use it in your MQL project. The paper presents the internal design of the editor and a user guide. Source codes are attached.
Timeseries in DoEasy library (part 43): Classes of indicator buffer objects
Timeseries in DoEasy library (part 43): Classes of indicator buffer objects

Timeseries in DoEasy library (part 43): Classes of indicator buffer objects

The article considers the development of indicator buffer object classes as descendants of the abstract buffer object simplifying declaration and working with indicator buffers, while creating custom indicator programs based on DoEasy library.
Multicurrency monitoring of trading signals (Part 5): Composite signals
Multicurrency monitoring of trading signals (Part 5): Composite signals

Multicurrency monitoring of trading signals (Part 5): Composite signals

In the fifth article related to the creation of a trading signal monitor, we will consider composite signals and will implement the necessary functionality. In earlier versions, we used simple signals, such as RSI, WPR and CCI, and we also introduced the possibility to use custom indicators.
Native Twitter Client: Part 2
Native Twitter Client: Part 2

Native Twitter Client: Part 2

A Twitter client implemented as MQL class to allow you to send tweets with photos. All you need is to include a single self contained include file and off you go to tweet all your wonderful charts and signals.
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.
Native Twitter Client for MT4 and MT5 without DLL
Native Twitter Client for MT4 and MT5 without DLL

Native Twitter Client for MT4 and MT5 without DLL

Ever wanted to access tweets and/or post your trade signals on Twitter ? Search no more, these on-going article series will show you how to do it without using any DLL. Enjoy the journey of implementing Twitter API using MQL. In this first part, we will follow the glory path of authentication and authorization in accessing Twitter API.
Timeseries in DoEasy library (part 41): Sample multi-symbol multi-period indicator
Timeseries in DoEasy library (part 41): Sample multi-symbol multi-period indicator

Timeseries in DoEasy library (part 41): Sample multi-symbol multi-period indicator

In the article, we will consider a sample multi-symbol multi-period indicator using the timeseries classes of the DoEasy library displaying the chart of a selected currency pair on a selected timeframe as candles in a subwindow. I am going to modify the library classes a bit and create a separate file for storing enumerations for program inputs and selecting a compilation language.
preview
Continuous Walk-Forward Optimization (Part 7): Binding Auto Optimizer's logical part with graphics and controlling graphics from the program

Continuous Walk-Forward Optimization (Part 7): Binding Auto Optimizer's logical part with graphics and controlling graphics from the program

This article describes the connection of the graphical part of the auto optimizer program with its logical part. It considers the optimization launch process, from a button click to task redirection to the optimization manager.
Timeseries in DoEasy library (part 40): Library-based indicators - updating data in real time
Timeseries in DoEasy library (part 40): Library-based indicators - updating data in real time

Timeseries in DoEasy library (part 40): Library-based indicators - updating data in real time

The article considers the development of a simple multi-period indicator based on the DoEasy library. Let's improve the timeseries classes to receive data from any timeframes to display it on the current chart period.
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.
preview
Continuous Walk-Forward Optimization (Part 6): Auto optimizer's logical part and structure

Continuous Walk-Forward Optimization (Part 6): Auto optimizer's logical part and structure

We have previously considered the creation of automatic walk-forward optimization. This time, we will proceed to the internal structure of the auto optimizer tool. The article will be useful for all those who wish to further work with the created project and to modify it, as well as for those who wish to understand the program logic. The current article contains UML diagrams which present the internal structure of the project and the relationships between objects. It also describes the process of optimization start, but it does not contain the description of the optimizer implementation process.
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2

MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 2

This paper continues checking the new conception to describe the window interface of MQL programs, using the structures of MQL. Automatically creating GUI based on the MQL markup provides additional functionality for caching and dynamically generating the elements and controlling the styles and new schemes for processing the events. Attached is an enhanced version of the standard library of controls.
Timeseries in DoEasy library (part 39): Library-based indicators - preparing data and timeseries events
Timeseries in DoEasy library (part 39): Library-based indicators - preparing data and timeseries events

Timeseries in DoEasy library (part 39): Library-based indicators - preparing data and timeseries events

The article deals with applying DoEasy library for creating multi-symbol multi-period indicators. We are going to prepare the library classes to work within indicators and test creating timeseries to be used as data sources in indicators. We will also implement creating and sending timeseries events.
Multicurrency monitoring of trading signals (Part 4): Enhancing functionality and improving the signal search system
Multicurrency monitoring of trading signals (Part 4): Enhancing functionality and improving the signal search system

Multicurrency monitoring of trading signals (Part 4): Enhancing functionality and improving the signal search system

In this part, we expand the trading signal searching and editing system, as well as introduce the possibility to use custom indicators and add program localization. We have previously created a basic system for searching signals, but it was based on a small set of indicators and a simple set of search rules.
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 1
MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 1

MQL as a Markup Tool for the Graphical Interface of MQL Programs. Part 1

This paper proposes a new conception to describe the window interface of MQL programs, using the structures of MQL. Special classes transform the viewable MQL markup into the GUI elements and allow manage them, set up their properties, and process the events in a unified manner. It also provides some examples of using the markup for the dialogs and elements of a standard library.
Timeseries in DoEasy library (part 38): Timeseries collection - real-time updates and accessing data from the program
Timeseries in DoEasy library (part 38): Timeseries collection - real-time updates and accessing data from the program

Timeseries in DoEasy library (part 38): Timeseries collection - real-time updates and accessing data from the program

The article considers real-time update of timeseries data and sending messages about the "New bar" event to the control program chart from all timeseries of all symbols for the ability to handle these events in custom programs. The "New tick" class is used to determine the need to update timeseries for the non-current chart symbol and periods.
Multicurrency monitoring of trading signals (Part 3): Introducing search algorithms
Multicurrency monitoring of trading signals (Part 3): Introducing search algorithms

Multicurrency monitoring of trading signals (Part 3): Introducing search algorithms

In the previous article, we developed the visual part of the application, as well as the basic interaction of GUI elements. This time we are going to add internal logic and the algorithm of trading signal data preparation, as well us the ability to set up signals, to search them and to visualize them in the monitor.
Applying OLAP in trading (part 4): Quantitative and visual analysis of tester reports
Applying OLAP in trading (part 4): Quantitative and visual analysis of tester reports

Applying OLAP in trading (part 4): Quantitative and visual analysis of tester reports

The article offers basic tools for the OLAP analysis of tester reports relating to single passes and optimization results. The tool can work with standard format files (tst and opt), and it also provides a graphical interface. MQL source codes are attached below.
Timeseries in DoEasy library (part 37): Timeseries collection - database of timeseries by symbols and periods
Timeseries in DoEasy library (part 37): Timeseries collection - database of timeseries by symbols and periods

Timeseries in DoEasy library (part 37): Timeseries collection - database of timeseries by symbols and periods

The article deals with the development of the timeseries collection of specified timeframes for all symbols used in the program. We are going to develop the timeseries collection, the methods of setting collection's timeseries parameters and the initial filling of developed timeseries with historical data.
preview
Continuous Walk-Forward Optimization (Part 5): Auto Optimizer project overview and creation of a GUI

Continuous Walk-Forward Optimization (Part 5): Auto Optimizer project overview and creation of a GUI

This article provides further description of the walk-forward optimization in the MetaTrader 5 terminal. In previous articles, we considered methods for generating and filtering the optimization report and started analyzing the internal structure of the application responsible for the optimization process. The Auto Optimizer is implemented as a C# application and it has its own graphical interface. The fifth article is devoted to the creation of this graphical interface.
Forecasting Time Series (Part 2): Least-Square Support-Vector Machine (LS-SVM)
Forecasting Time Series (Part 2): Least-Square Support-Vector Machine (LS-SVM)

Forecasting Time Series (Part 2): Least-Square Support-Vector Machine (LS-SVM)

This article deals with the theory and practical application of the algorithm for forecasting time series, based on support-vector method. It also proposes its implementation in MQL and provides test indicators and Expert Advisors. This technology has not been implemented in MQL yet. But first, we have to get to know math for it.
Projects assist in creating profitable trading robots! Or at least, so it seems
Projects assist in creating profitable trading robots! Or at least, so it seems

Projects assist in creating profitable trading robots! Or at least, so it seems

A big program starts with a small file, which then grows in size as you keep adding more functions and objects. Most robot developers utilize include files to handle this problem. However, there is a better solution: start developing any trading application in a project. There are so many reasons to do so.
preview
Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer)

Continuous Walk-Forward Optimization (Part 4): Optimization Manager (Auto Optimizer)

The main purpose of the article is to describe the mechanism of working with our application and its capabilities. Thus the article can be treated as an instruction on how to use the application. It covers all possible pitfalls and specifics of the application usage.
Timeseries in DoEasy library (part 36): Object of timeseries for all used symbol periods
Timeseries in DoEasy library (part 36): Object of timeseries for all used symbol periods

Timeseries in DoEasy library (part 36): Object of timeseries for all used symbol periods

In this article, we will consider combining the lists of bar objects for each used symbol period into a single symbol timeseries object. Thus, each symbol will have an object storing the lists of all used symbol timeseries periods.
Forecasting Time Series (Part 1): Empirical Mode Decomposition (EMD) Method
Forecasting Time Series (Part 1): Empirical Mode Decomposition (EMD) Method

Forecasting Time Series (Part 1): Empirical Mode Decomposition (EMD) Method

This article deals with the theory and practical use of the algorithm for forecasting time series, based on the empirical decomposition mode. It proposes the MQL implementation of this method and presents test indicators and Expert Advisors.
Timeseries in DoEasy library (part 35): Bar object and symbol timeseries list
Timeseries in DoEasy library (part 35): Bar object and symbol timeseries list

Timeseries in DoEasy library (part 35): Bar object and symbol timeseries list

This article starts a new series about the creation of the DoEasy library for easy and fast program development. In the current article, we will implement the library functionality for accessing and working with symbol timeseries data. We are going to create the Bar object storing the main and extended timeseries bar data, and place bar objects to the timeseries list for convenient search and sorting of the objects.
Multicurrency monitoring of trading signals (Part 2): Implementation of the visual part of the application
Multicurrency monitoring of trading signals (Part 2): Implementation of the visual part of the application

Multicurrency monitoring of trading signals (Part 2): Implementation of the visual part of the application

In the previous article, we created the application framework, which we will use as the basis for all further work. In this part, we will proceed with the development: we will create the visual part of the application and will configure basic interaction of interface elements.
Applying network functions, or MySQL without DLL: Part II - Program for monitoring changes in signal properties
Applying network functions, or MySQL without DLL: Part II - Program for monitoring changes in signal properties

Applying network functions, or MySQL without DLL: Part II - Program for monitoring changes in signal properties

In the previous part, we considered the implementation of the MySQL connector. In this article, we will consider its application by implementing the service for collecting signal properties and the program for viewing their changes over time. The implemented example has practical sense if users need to observe changes in properties that are not displayed on the signal's web page.
Library for easy and quick development of MetaTrader programs (part XXXIV): Pending trading requests - removing and modifying orders and positions under certain conditions
Library for easy and quick development of MetaTrader programs (part XXXIV): Pending trading requests - removing and modifying orders and positions under certain conditions

Library for easy and quick development of MetaTrader programs (part XXXIV): Pending trading requests - removing and modifying orders and positions under certain conditions

In this article, we will complete the description of the pending request trading concept and create the functionality for removing pending orders, as well as modifying orders and positions under certain conditions. Thus, we are going to have the entire functionality enabling us to develop simple custom strategies, or rather EA behavior logic activated upon user-defined conditions.
Applying network functions, or MySQL without DLL: Part I - Connector
Applying network functions, or MySQL without DLL: Part I - Connector

Applying network functions, or MySQL without DLL: Part I - Connector

MetaTrader 5 has received network functions recently. This opened up great opportunities for programmers developing products for the Market. Now they can implement things that required dynamic libraries before. In this article, we will consider them using the implementation of the MySQL as an example.
preview
How to create 3D graphics using DirectX in MetaTrader 5

How to create 3D graphics using DirectX in MetaTrader 5

3D graphics provide excellent means for analyzing huge amounts of data as they enable the visualization of hidden patterns. These tasks can be solved directly in MQL5, while DireсtX functions allow creating three-dimensional object. Thus, it is even possible to create programs of any complexity, even 3D games for MetaTrader 5. Start learning 3D graphics by drawing simple three-dimensional shapes.
Library for easy and quick development of MetaTrader programs (part XXXIII): Pending trading requests - closing positions under certain conditions
Library for easy and quick development of MetaTrader programs (part XXXIII): Pending trading requests - closing positions under certain conditions

Library for easy and quick development of MetaTrader programs (part XXXIII): Pending trading requests - closing positions under certain conditions

We continue the development of the library functionality featuring trading using pending requests. We have already implemented sending conditional trading requests for opening positions and placing pending orders. In the current article, we will implement conditional position closure – full, partial and closing by an opposite position.
Applying OLAP in trading (part 3): Analyzing quotes for the development of trading strategies
Applying OLAP in trading (part 3): Analyzing quotes for the development of trading strategies

Applying OLAP in trading (part 3): Analyzing quotes for the development of trading strategies

In this article we will continue dealing with the OLAP technology applied to trading. We will expand the functionality presented in the first two articles. This time we will consider the operational analysis of quotes. We will put forward and test the hypotheses on trading strategies based on aggregated historical data. The article presents Expert Advisors for studying bar patterns and adaptive trading.
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.
Library for easy and quick development of MetaTrader programs (part XXXI): Pending trading requests - opening positions under certain conditions
Library for easy and quick development of MetaTrader programs (part XXXI): Pending trading requests - opening positions under certain conditions

Library for easy and quick development of MetaTrader programs (part XXXI): Pending trading requests - opening positions under certain conditions

Starting with this article, we are going to develop a functionality allowing users to trade using pending requests under certain conditions, for example, when reaching a certain time limit, exceeding a specified profit or closing a position by stop loss.
Multicurrency monitoring of trading signals (Part 1): Developing the application structure
Multicurrency monitoring of trading signals (Part 1): Developing the application structure

Multicurrency monitoring of trading signals (Part 1): Developing the application structure

In this article, we will discuss the idea of creating a multicurrency monitor of trading signals and will develop a future application structure along with its prototype, as well as create its framework for further operation. The article presents a step-by-step creation of a flexible multicurrency application which will enable the generation of trading signals and which will assist traders in finding the desired signals.
Econometric approach to finding market patterns: Autocorrelation, Heat Maps and Scatter Plots
Econometric approach to finding market patterns: Autocorrelation, Heat Maps and Scatter Plots

Econometric approach to finding market patterns: Autocorrelation, Heat Maps and Scatter Plots

The article presents an extended study of seasonal characteristics: autocorrelation heat maps and scatter plots. The purpose of the article is to show that "market memory" is of seasonal nature, which is expressed through maximized correlation of increments of arbitrary order.