Articles with MQL5 programming examples

Access a huge collection of articles with code examples showing how to create indicators and trading robots for the MetaTrader platform in the MQL5 language. Source codes are attached to the articles, so you can open them in MetaEditor and run them to see how the applications work.

These articles will be useful both for those who have just started exploring automated trading and for professional traders with programming experience. They feature not only examples, but also contain new ideas.

Add a new article
latest | best

Multi-symbol balance graph in MetaTrader 5

The article provides an example of an MQL application with its graphical interface featuring multi-symbol balance and deposit drawdown graphs based on the last test results

Deep Neural Networks (Part V). Bayesian optimization of DNN hyperparameters

The article considers the possibility to apply Bayesian optimization to hyperparameters of deep neural networks, obtained by various training variants. The classification quality of a DNN with the

How to create a graphical panel of any complexity level

The article features a detailed explanation of how to create a panel on the basis of the CAppDialog class and how to add controls to the panel. It provides the description of the panel structure and a

How to create Requirements Specification for ordering an indicator

Most often the first step in the development of a trading system is the creation of a technical indicator, which can identify favorable market behavior patterns. A professionally developed indicator

LifeHack for traders: Blending ForEach with defines (#define)

The article is an intermediate step for those who still writes in MQL4 and has no desire to switch to MQL5. We continue to search for opportunities to write code in MQL4 style. This time, we will look

Custom Strategy Tester based on fast mathematical calculations

The article describes the way to create a custom strategy tester and a custom analyzer of the optimization passes. After reading it, you will understand how the math calculations mode and the

The Channel Breakout pattern

Price trends form price channels that can be observed on financial symbol charts. The breakout of the current channel is one of the strong trend reversal signals. In this article, I suggest a way to

Momentum Pinball trading strategy

In this article, we continue to consider writing the code to trading systems described in a book by Linda B. Raschke and Laurence A. Connors “Street Smarts: High Probability Short-Term Trading

Creating a custom news feed for MetaTrader 5

In this article we look at the possibility of creating a flexible news feed that offers more options in terms of the type of news and also its source. The article will show how a web API can be

Trading DiNapoli levels

The article considers one of the variants for Expert Advisor practical realization to trade DiNapoli levels using MQL5 standard tools. Its performance is tested and conclusions are made

Fuzzy Logic in trading strategies

The article considers an example of applying the fuzzy logic to build a simple trading system, using the Fuzzy library. Variants for improving the system by combining fuzzy logic, genetic algorithms

Practical evaluation of the adaptive market following method

The main difference of the trading system proposed in the article is the use of mathematical tools for analyzing stock quotes. The system applies digital filtering and spectral estimation of discrete

Implementing a Scalping Market Depth Using the CGraphic Library

In this article, we will create the basic functionality of a scalping Market Depth tool. Also, we will develop a tick chart based on the CGraphic library and integrate it with the order book. Using

Auto search for divergences and convergences

The article considers all kinds of divergence: simple, hidden, extended, triple, quadruple, convergence, as well as divergences of A, B and C classes. A universal indicator for their search and

Cross-Platform Expert Advisor: The CExpertAdvisor and CExpertAdvisors Classes

This article deals primarily with the classes CExpertAdvisor and CExpertAdvisors, which serve as the container for all the other components described in this article-series regarding cross-platform

Universal Expert Advisor: CUnIndicator and Use of Pending Orders (Part 9)

The article describes the work with indicators through the universal CUnIndicator class. In addition, new methods of working with pending orders are considered. Please note: from this point on, the

Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)

A new version of the graphics library for creating scientific charts (the CGraphic class) has been presented recently. This update of the developed library for creating graphical interfaces will

Cross-Platform Expert Advisor: Custom Stops, Breakeven and Trailing

This article discusses how custom stop levels can be set up in a cross-platform expert advisor. It also discusses a closely-related method by which the evolution of a stop level over time can be

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

Graphical Interfaces XI: Text edit boxes and Combo boxes in table cells (build 15)

In this update of the library, the Table control (the CTable class) will be supplemented with new options. The lineup of controls in the table cells is expanded, this time adding text edit boxes and

Creating and testing custom symbols in MetaTrader 5

Creating custom symbols pushes the boundaries in the development of trading systems and financial market analysis. Now traders are able to plot charts and test trading strategies on an unlimited

The Flag Pattern

The article provides the analysis of the following patterns: Flag, Pennant, Wedge, Rectangle, Contracting Triangle, Expanding Triangle. In addition to analyzing their similarities and differences, we

Cross-Platform Expert Advisor: Stops

This article discusses an implementation of stop levels in an expert advisor in order to make it compatible with the two platforms MetaTrader 4 and MetaTrader 5

Universal Expert Advisor: Accessing Symbol Properties (Part 8)

The eighth part of the article features the description of the CSymbol class, which is a special object that provides access to any trading instrument. When used inside an Expert Advisor, the class

Graphical Interfaces XI: Rendered controls (build 14.2)

In the new version of the library, all controls will be drawn on separate graphical objects of the OBJ_BITMAP_LABEL type. We will also continue to describe the optimization of code: changes in the

Graphical Interfaces XI: Refactoring the Library code (build 14.1)

As the library grows, its code must be optimized again in order to reduce its size. The version of the library described in this article has become even more object-oriented. This made the code easier

Custom indicators and infographics in CCanvas

The article considers new types of indicators with more complex structural implementation. It also describes the development of pseudo-3D indicator types and dynamic infographics

Cross-Platform Expert Advisor: Time Filters

This article discusses the implementation of various methods of time filtering a cross-platform expert advisor. The time filter classes are responsible for checking whether or not a given time falls

Cross-Platform Expert Advisor: Money Management

This article discusses the implementation of money management method for a cross-platform expert advisor. The money management classes are responsible for the calculation of the lot size to be used

An example of an indicator drawing Support and Resistance lines

The article provides an example of how to implement an indicator for drawing support and resistance lines based on formalized conditions. In addition to having a ready-to-use indicator, you will see

Graphical Interfaces X: Text selection in the Multiline Text box (build 13)

This article will implement the ability to select text using various key combinations and deletion of the selected text, similar to the way it is done in any other text editor. In addition, we will

Wolfe Waves

The graphical method proposed by Bill Wolfe allows to detect a pattern, based on which a moment and direction for entry can be found, and also it helps forecast the target which the price should

Thomas DeMark's Sequential (TD SEQUENTIAL) using artificial intelligence

In this article, I will tell you how to successfully trade by merging a very well-known strategy and a neural network. It will be about the Thomas DeMark's Sequential strategy with the use of an

Cross-Platform Expert Advisor: Signals

This article discusses the CSignal and CSignals classes which will be used in cross-platform expert advisors. It examines the differences between MQL4 and MQL5 on how particular data needed for

MQL5 Cookbook - Creating a ring buffer for fast calculation of indicators in a sliding window

The ring buffer is the simplest and the most efficient way to arrange data when performing calculations in a sliding window. The article describes the algorithm and shows how it simplifies

MQL5 Cookbook - Pivot trading signals

The article describes the development and implementation of a class for sending signals based on pivots — reversal levels. This class is used to form a strategy applying the Standard Library

Graphical Interfaces X: Word wrapping algorithm in the Multiline Text box (build 12)

We continue to develop the Multiline Text box control. This time our task is to implement an automatic word wrapping in case a text box width overflow occurs, or a reverse word wrapping of the text to

Universal Trend with the Graphical Interface

In this article a universal trend indicator is created based on a number of standard indicators. An additionally created graphical interface allows selecting the type of indicator and adjusting its

Graphical Interfaces X: Sorting, rebuilding the table and controls in the cells (build 11)

We continue to add new features to the rendered table: data sorting, managing the number of columns and rows, setting the table cell types to place controls into them

A Universal Channel with the Graphical Interface

All channel indicators are displayed as three lines, including central, top and bottom lines. The drawing principle of the central line is similar to a moving average, while the moving average