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
MQL5: Create Your Own Indicator
MQL5: Create Your Own Indicator

MQL5: Create Your Own Indicator

What is an indicator? It is a set of calculated values that we want to be displayed on the screen in a convenient way. Sets of values are represented in programs as arrays. Thus, creation of an indicator means writing an algorithm that handles some arrays (price arrays) and records results of handling to other arrays (indicator values). By describing creation of True Strength Index, the author shows how to write indicators in MQL5.
MQL5 Programming Basics: Time
MQL5 Programming Basics: Time

MQL5 Programming Basics: Time

The article focuses on standard MQL5 functions for working with time, as well as programming techniques and practically useful functions for working with time that are required when creating Expert Advisors and indicators. Particular attention is paid to the general theory of time measurement. This article should be of interest primarily to novice MQL5 programmers.
How to create bots for Telegram in MQL5
How to create bots for Telegram in MQL5

How to create bots for Telegram in MQL5

This article contains step-by-step instructions for creating bots for Telegram in MQL5. This information may prove useful for users who wish to synchronize their trading robot with a mobile device. There are samples of bots in the article that provide trading signals, search for information on websites, send information about the account balance, quotes and screenshots of charts to you smart phone.
MQL5 Programming Basics: Arrays
MQL5 Programming Basics: Arrays

MQL5 Programming Basics: Arrays

Arrays are an integral part of almost any programming language along with variables and functions. The article should be of interest primarily to novice MQL5 programmers, while experienced programmers will have a good opportunity to summarize and systematize their knowledge.
Why Is MQL5 Market the Best Place for Selling Trading Strategies and Technical Indicators
Why Is MQL5 Market the Best Place for Selling Trading Strategies and Technical Indicators

Why Is MQL5 Market the Best Place for Selling Trading Strategies and Technical Indicators

MQL5.community Market provides Expert Advisors developers with the already formed market consisting of thousands of potential customers. This is the best place for selling trading robots and technical indicators!
How to Create Your Own Trailing Stop
How to Create Your Own Trailing Stop

How to Create Your Own Trailing Stop

The basic rule of trader - let profit to grow, cut off losses! This article considers one of the basic techniques, allowing to follow this rule - moving the protective stop level (Stop loss level) after increasing position profit, i.e. - Trailing Stop level. You'll find the step by step procedure to create a class for trailing stop on SAR and NRTR indicators. Everyone will be able to insert this trailing stop into their experts or use it independently to control positions in their accounts.
Forecasting market movements using the Bayesian classification and indicators based on Singular Spectrum Analysis
Forecasting market movements using the Bayesian classification and indicators based on Singular Spectrum Analysis

Forecasting market movements using the Bayesian classification and indicators based on Singular Spectrum Analysis

The article considers the ideology and methodology of building a recommendatory system for time-efficient trading by combining the capabilities of forecasting with the singular spectrum analysis (SSA) and important machine learning method on the basis of Bayes' Theorem.
Automata-Based Programming as a New Approach to Creating Automated Trading Systems
Automata-Based Programming as a New Approach to Creating Automated Trading Systems

Automata-Based Programming as a New Approach to Creating Automated Trading Systems

This article takes us to a whole new direction in developing EAs, indicators and scripts in MQL4 and MQL5. In the future, this programming paradigm will gradually become the base standard for all traders in implementation of EAs. Using the automata-based programming paradigm, the MQL5 and MetaTrader 5 developers will be anywhere near being able to create a new language - MQL6 - and a new platform - MetaTrader 6.
Quick Start: Short Guide for Beginners
Quick Start: Short Guide for Beginners

Quick Start: Short Guide for Beginners

Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.
Automated Optimization of an EA for MetaTrader 5
Automated Optimization of an EA for MetaTrader 5

Automated Optimization of an EA for MetaTrader 5

This article describes the implementation of a self-optimization mechanism under MetaTrader 5.
Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5

Step on New Rails: Custom Indicators in MQL5

I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
How to Access the MySQL Database from MQL5 (MQL4)
How to Access the MySQL Database from MQL5 (MQL4)

How to Access the MySQL Database from MQL5 (MQL4)

The article describes the development of an interface between MQL and the MySQL database. It discusses existing practical solutions and offers a more convenient way to implement a library for working with databases. The article contains a detailed description of the functions, the interface structure, examples and some of specific features of working with MySQL. As for the software solutions, the article attachments include the files of dynamic libraries, documentation and script examples for the MQL4 and MQL5 languages.
ZUP - Universal ZigZag with Pesavento patterns. Search for patterns
ZUP - Universal ZigZag with Pesavento patterns. Search for patterns

ZUP - Universal ZigZag with Pesavento patterns. Search for patterns

The ZUP indicator platform allows searching for multiple known patterns, parameters for which have already been set. These parameters can be edited to suit your requirements. You can also create new patterns using the ZUP graphical interfaces and save their parameters to a file. After that you can quickly check, whether these new patterns can be found on charts.
Using MetaTrader 5 Indicators with ENCOG Machine Learning Framework for Timeseries Prediction
Using MetaTrader 5 Indicators with ENCOG Machine Learning Framework for Timeseries Prediction

Using MetaTrader 5 Indicators with ENCOG Machine Learning Framework for Timeseries Prediction

This article presents connecting MetaTrader 5 to ENCOG - Advanced Neural Network and Machine Learning Framework. It contains description and implementation of a simple neural network indicator based on a standard technical indicators and an Expert Advisor based on a neural indicator. All source code, compiled binaries, DLLs and an exemplary trained network are attached to the article.
Automatic construction of support and resistance lines
Automatic construction of support and resistance lines

Automatic construction of support and resistance lines

The article deals with automatic construction of support/resistance lines using local tops and bottoms of price charts. The well-known ZigZag indicator is applied to define these extreme values.
Tips for an Effective Product Presentation on the Market
Tips for an Effective Product Presentation on the Market

Tips for an Effective Product Presentation on the Market

Selling programs to traders effectively does not only require writing an efficient and useful product and then publishing it on the Market. It is vital to provide a comprehensive, detailed description and good illustrations. A quality logo and correct screenshots are equally as important as the "true coding". Bear in mind a simple formula: no downloads = no sales.
MQL5 Wizard: Creating Expert Advisors without Programming
MQL5 Wizard: Creating Expert Advisors without Programming

MQL5 Wizard: Creating Expert Advisors without Programming

Do you want to try out a trading strategy while wasting no time for programming? In MQL5 Wizard you can simply select the type of trading signals, add modules of trailing positions and money management - and your work is done! Create your own implementations of modules or order them via the Jobs service - and combine your new modules with existing ones.
Implementing indicator calculations into an Expert Advisor code
Implementing indicator calculations into an Expert Advisor code

Implementing indicator calculations into an Expert Advisor code

The reasons for moving an indicator code to an Expert Advisor may vary. How to assess the pros and cons of this approach? The article describes implementing an indicator code into an EA. Several experiments are conducted to assess the speed of the EA's operation.
Developing custom indicators using CCanvas class
Developing custom indicators using CCanvas class

Developing custom indicators using CCanvas class

The article deals with developing custom graphical indicators using graphical primitives of the CCanvas class.
preview
How to create a graphical panel of any complexity level

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 scheme, which shows the inheritance of objects. From this article, you will also learn how events are handled and how they are delivered to dependent controls. Additional examples show how to edit panel parameters, such as the size and the background color.
An Example of a Trading System Based on a Heiken-Ashi Indicator
An Example of a Trading System Based on a Heiken-Ashi Indicator

An Example of a Trading System Based on a Heiken-Ashi Indicator

In this article we look into the question of using a Heiken-Ashi indicator in trading. Based on this indicator, a simple trading system is considered and an MQL5 Expert Advisor is written. Trading operations are implemented on the bases of classes of the Standard class library. The testing results of the reviewed trading strategy, are based on the history, and obtained using the built-in MetaTrader 5 strategy tester, are provided in the article.
The Implementation of Automatic Analysis of the Elliott Waves in MQL5
The Implementation of Automatic Analysis of the Elliott Waves in MQL5

The Implementation of Automatic Analysis of the Elliott Waves in MQL5

One of the most popular methods of market analysis is the Elliott Wave Principle. However, this process is quite complicated, which leads us to the use of additional tools. One of such instruments is the automatic marker. This article describes the creation of an automatic analyzer of Elliott Waves in MQL5 language.
Third Generation Neural Networks: Deep Networks
Third Generation Neural Networks: Deep Networks

Third Generation Neural Networks: Deep Networks

This article is dedicated to a new and perspective direction in machine learning - deep learning or, to be precise, deep neural networks. This is a brief review of second generation neural networks, the architecture of their connections and main types, methods and rules of learning and their main disadvantages followed by the history of the third generation neural network development, their main types, peculiarities and training methods. Conducted are practical experiments on building and training a deep neural network initiated by the weights of a stacked autoencoder with real data. All the stages from selecting input data to metric derivation are discussed in detail. The last part of the article contains a software implementation of a deep neural network in an Expert Advisor with a built-in indicator based on MQL4/R.
MQL5 Programming Basics: Files
MQL5 Programming Basics: Files

MQL5 Programming Basics: Files

This practice-oriented article focuses on working with files in MQL5. It offers a number of simple tasks allowing you to grasp the basics and hone your skills.
Visual strategy builder. Creating trading robots without programming
Visual strategy builder. Creating trading robots without programming

Visual strategy builder. Creating trading robots without programming

This article presents a visual strategy builder. It is shown how any user can create trading robots and utilities without programming. Created Expert Advisors are fully functional and can be tested in the strategy tester, optimized in the cloud or executed live on real time charts.
Creating and testing custom symbols in MetaTrader 5
Creating and testing custom symbols in MetaTrader 5

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 number of financial instruments.
The Price Histogram (Market Profile) and its implementation in MQL5
The Price Histogram (Market Profile) and its implementation in MQL5

The Price Histogram (Market Profile) and its implementation in MQL5

The Market Profile was developed by trully brilliant thinker Peter Steidlmayer. He suggested to use the alternative representation of information about "horizontal" and "vertical" market movements that leads to completely different set of models. He assumed that there is an underlying pulse of the market or a fundamental pattern called the cycle of equilibrium and disequilibrium. In this article I will consider Price Histogram — a simplified model of Market Profile, and will describe its implementation in MQL5.
Market Theory
Market Theory

Market Theory

A logically complete market theory that would cover all types and varieties of markets for goods and services, micro and macro markets like Forex, hasn't been available until now. This article covers the essence of a new market theory based on the profit analysis, reveals patterns of the current price change and the principle of the mechanism operation that allows the price to find its most optimal value by forming a chain of virtual prices that can develop the controlling influence on the actual price. Mechanisms of formation and change of market trends are also identified here.
How to reduce trader's risks
How to reduce trader's risks

How to reduce trader's risks

Trading in financial markets is associated with a whole range of risks that should be taken into account in the algorithms of trading systems. Reducing such risks is the most important task to make a profit when trading.
The "New Bar" Event Handler
The "New Bar" Event Handler

The "New Bar" Event Handler

MQL5 programming language is capable of solving problems on a brand new level. Even those tasks, that already have such solutions, thanks to object oriented programming can rise to a higher level. In this article we take a specially simple example of checking new bar on a chart, that was transformed into rather powerful and versatile tool. What tool? Find out in this article.
Neural Networks: From Theory to Practice
Neural Networks: From Theory to Practice

Neural Networks: From Theory to Practice

Nowadays, every trader must have heard of neural networks and knows how cool it is to use them. The majority believes that those who can deal with neural networks are some kind of superhuman. In this article, I will try to explain to you the neural network architecture, describe its applications and show examples of practical use.
Introduction to the Empirical Mode Decomposition Method
Introduction to the Empirical Mode Decomposition Method

Introduction to the Empirical Mode Decomposition Method

This article serves to familiarize the reader with the empirical mode decomposition (EMD) method. It is the fundamental part of the Hilbert–Huang transform and is intended for analyzing data from nonstationary and nonlinear processes. This article also features a possible software implementation of this method along with a brief consideration of its peculiarities and gives some simple examples of its use.
Several Ways of Finding a Trend in MQL5
Several Ways of Finding a Trend in MQL5

Several Ways of Finding a Trend in MQL5

Any trader would give a lot for opportunity to accurately detect a trend at any given time. Perhaps, this is the Holy Grail that everyone is looking for. In this article we will consider several ways to detect a trend. To be more precise - how to program several classical ways to detect a trend by means of MQL5.
Exposing C# code to MQL5 using unmanaged exports
Exposing C# code to MQL5 using unmanaged exports

Exposing C# code to MQL5 using unmanaged exports

In this article I presented different methods of interaction between MQL5 code and managed C# code. I also provided several examples on how to marshal MQL5 structures against C# and how to invoke exported DLL functions in MQL5 scripts. I believe that the provided examples may serve as a basis for future research in writing DLLs in managed code. This article also open doors for MetaTrader to use many libraries that are already implemented in C#.
80-20 trading strategy
80-20 trading strategy

80-20 trading strategy

The article describes the development of tools (indicator and Expert Advisor) for analyzing the '80-20' trading strategy. The trading strategy rules are taken from the work "Street Smarts. High Probability Short-Term Trading Strategies" by Linda Raschke and Laurence Connors. We are going to formalize the strategy rules using the MQL5 language and test the strategy-based indicator and EA on the recent market history.
How to create Requirements Specification for ordering an indicator
How to create Requirements Specification for ordering an indicator

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 can be ordered from the Freelance service. From this article you will learn how to create a proper Requirements Specification, which will help you to obtain the desired indicator faster.
Universal ZigZag
Universal ZigZag

Universal ZigZag

ZigZag is one of the most popular indicators among the MetaTrader 5 users. The article analyzes the possibilities for creating various versions of the ZigZag. The result is a universal indicator with ample opportunities to extend its functionality, which is useful in the development of trading experts and other indicators.
Calculator of signals
Calculator of signals

Calculator of signals

The calculator of signals operates directly from the MetaTrader 5 terminal, which is a serious advantage, since the terminal provides a preliminary selection and sorts out signals. This way, users can see in the terminal only the signals that ensure a maximum compatibility with their trading accounts.
preview
How to make $1,000,000 off algorithmic trading? Use MQL5.com services!

How to make $1,000,000 off algorithmic trading? Use MQL5.com services!

All traders visit the market with the goal of earning their first million dollars. How to do that without excessive risk and start-up budget? MQL5 services provide such opportunity for developers and traders from around the world.
William Blau's Indicators and Trading Systems in MQL5. Part 1: Indicators
William Blau's Indicators and Trading Systems in MQL5. Part 1: Indicators

William Blau's Indicators and Trading Systems in MQL5. Part 1: Indicators

The article presents the indicators, described in the book by William Blau "Momentum, Direction, and Divergence". William Blau's approach allows us to promptly and accurately approximate the fluctuations of the price curve, to determine the trend of the price movements and the turning points, and eliminate the price noise. Meanwhile, we are also able to detect the overbought/oversold states of the market, and signals, indicating the end of a trend and reversal of the price movement.