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
How to Subscribe to Trading Signals
How to Subscribe to Trading Signals

How to Subscribe to Trading Signals

The Signals service introduces social trading with MetaTrader 4 and MetaTrader 5. The Service is integrated into the trading platform, and allows anyone to easily copy trades of professional traders. Select any of the thousands of signal providers, subscribe in a few clicks and the provider's trades will be copied on your account.
How to purchase a trading robot from the MetaTrader Market and to install it?
How to purchase a trading robot from the MetaTrader Market and to install it?

How to purchase a trading robot from the MetaTrader Market and to install it?

A product from the MetaTrader Market can be purchased on the MQL5.com website or straight from the MetaTrader 4 and MetaTrader 5 trading platforms. Choose a desired product that suits your trading style, pay for it using your preferred payment method, and activate the product.
How to Test a Trading Robot Before Buying
How to Test a Trading Robot Before Buying

How to Test a Trading Robot Before Buying

Buying a trading robot on MQL5 Market has a distinct benefit over all other similar options - an automated system offered can be thoroughly tested directly in the MetaTrader 5 terminal. Before buying, an Expert Advisor can and should be carefully run in all unfavorable modes in the built-in Strategy Tester to get a complete grasp of the system.
Payments and payment methods
Payments and payment methods

Payments and payment methods

MQL5.community Services offer great opportunities for traders as well as for the developers of applications for the MetaTrader terminal. In this article, we explain how payments for MQL5 services are performed, how the earned money can be withdraw, and how the operation security is ensured.
MetaTrader 5 on Linux
MetaTrader 5 on Linux

MetaTrader 5 on Linux

In this article, we demonstrate an easy way to install MetaTrader 5 on popular Linux versions — Ubuntu and Debian. These systems are widely used on server hardware as well as on traders’ personal computers.
MetaTrader 5 on Mac OS
MetaTrader 5 on Mac OS

MetaTrader 5 on Mac OS

Apple products have become very popular. MetaQuotes Software Corp. attentively follows the progress of the IT industry and has already released the special mobile applications for iOS-based devices - MetaTrader 4 for iPhone and MetaTrader 5 for iPhone. There are many topics on MQL5.community forum, where people are seeking a solution for running MetaTrader 5 under Mac OS operating system. In this article, you will find out how to work with MetaTrader 5 via the Apple's popular operating system.
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners

Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners

The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.
MetaQuotes ID in MetaTrader Mobile Terminal
MetaQuotes ID in MetaTrader Mobile Terminal

MetaQuotes ID in MetaTrader Mobile Terminal

Android and iOS powered devices offer us many features we do not even know about. One of these features is push notifications allowing us to receive personal messages, regardless of our phone number or mobile network operator. MetaTrader mobile terminal already can receive such messages right from your trading robot. You should only know MetaQuotes ID of your device. More than 9 000 000 mobile terminals have already received it.
preview
How to become a Signals Provider for MetaTrader 4 and MetaTrader 5

How to become a Signals Provider for MetaTrader 4 and MetaTrader 5

Do you want to offer your trading signals and make profit? Register on MQL5.com website as a Seller, specify your trading account and offer traders a subscription to copy your trades.
General information on Trading Signals for MetaTrader 4 and MetaTrader 5
General information on Trading Signals for MetaTrader 4 and MetaTrader 5

General information on Trading Signals for MetaTrader 4 and MetaTrader 5

MetaTrader 4 / MetaTrader 5 Trading Signals is a service allowing traders to copy trading operations of a Signals Provider. Our goal was to develop the new massively used service protecting Subscribers and relieving them of unnecessary costs.
How to Prepare a Trading Account for Migration to Virtual Hosting
How to Prepare a Trading Account for Migration to Virtual Hosting

How to Prepare a Trading Account for Migration to Virtual Hosting

MetaTrader client terminal is perfect for automating trading strategies. It has all tools necessary for trading robot developers ‒ powerful C++ based MQL4/MQL5 programming language, convenient MetaEditor development environment and multi-threaded strategy tester that supports distributed computing in MQL5 Cloud Network. In this article, you will find out how to move your client terminal to the virtual environment with all custom elements.
MQL5 Cookbook: Getting properties of an open hedge position
MQL5 Cookbook: Getting properties of an open hedge position

MQL5 Cookbook: Getting properties of an open hedge position

MetaTrader 5 is a multi-asset platform. Moreover, it supports different position management systems. Such opportunities provide significantly expanded options for the implementation and formalization of trading ideas. In this article, we discuss methods of handling and accounting of position properties in the hedging mode. The article features a derived class, as well as examples showing how to get and process the properties of a hedge position.
How to publish a product on the Market
How to publish a product on the Market

How to publish a product on the Market

Start offering your trading applications to millions of MetaTrader users from around the world though the Market. The service provides a ready-made infrastructure: access to a large audience, licensing solutions, trial versions, publication of updates and acceptance of payments. You only need to complete a quick seller registration procedure and publish your product. Start generating additional profits from your programs using the ready-made technical base provided by the service.
Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5

Migrating from MQL4 to MQL5

This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.
Trade Operations in MQL5 - It's Easy
Trade Operations in MQL5 - It's Easy

Trade Operations in MQL5 - It's Easy

Almost all traders come to market to make money but some traders also enjoy the process itself. However, it is not only manual trading that can provide you with an exciting experience. Automated trading systems development can also be quite absorbing. Creating a trading robot can be as interesting as reading a good mystery novel.
Video tutorial: MetaTrader Signals Service
Video tutorial: MetaTrader Signals Service

Video tutorial: MetaTrader Signals Service

In just 15 minutes, this video tutorial explains what MetaTrader Signals Service is, and demonstrates in great detail how to subscribe to trade signals and how to become a signal provider in our service. By watching this tutorial, you will be able to subscribe to any trading signal, or publish and promote your own signals in our service.
MetaTrader 5 - More Than You Can Imagine!
MetaTrader 5 - More Than You Can Imagine!

MetaTrader 5 - More Than You Can Imagine!

The MetaTrader 5 client terminal has been developed from scratch and far surpasses its predecessor, of course. The new trading platform provides unlimited opportunities for trading in any financial market. Moreover, its functionality keeps expanding to offer even more useful features and convenience. So, it is now quite difficult to list all the numerous advantages of MetaTrader 5. We have tried to briefly describe them in one article, and we got surprised with the result' the article is far from brief!
MQL5.community - User Memo
MQL5.community - User Memo

MQL5.community - User Memo

You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
How to Order a Trading Robot in MQL5 and MQL4
How to Order a Trading Robot in MQL5 and MQL4

How to Order a Trading Robot in MQL5 and MQL4

"Freelance" is the largest freelance service for ordering MQL4/MQL5 trading robots and technical indicators. Hundreds of professional developers are ready to develop a custom trading application for the MetaTrader 4/5 terminal.
Trading account monitoring is an indispensable trader's tool
Trading account monitoring is an indispensable trader's tool

Trading account monitoring is an indispensable trader's tool

Trading account monitoring provides a detailed report on all completed deals. All trading statistics are collected automatically and provided to you as easy-to-understand diagrams and graphs.
Why Virtual Hosting On The MetaTrader 4 And MetaTrader 5 Is Better Than Usual VPS
Why Virtual Hosting On The MetaTrader 4 And MetaTrader 5 Is Better Than Usual VPS

Why Virtual Hosting On The MetaTrader 4 And MetaTrader 5 Is Better Than Usual VPS

The Virtual Hosting Cloud network was developed specially for MetaTrader 4 and MetaTrader 5 and has all the advantages of a native solution. Get the benefit of our free 24 hours offer - test out a virtual server right now.
MQL5: Analysis and Processing of Commodity Futures Trading Commission (CFTC) Reports in MetaTrader 5
MQL5: Analysis and Processing of Commodity Futures Trading Commission (CFTC) Reports in MetaTrader 5

MQL5: Analysis and Processing of Commodity Futures Trading Commission (CFTC) Reports in MetaTrader 5

In this article, we will develop a tool for CFTC report analysis. We will solve the following problem: to develop an indicator, that allows using the CFTC report data directly from the data files provided by Commission without an intermediate processing and conversion. Further, it can be used for the different purposes: to plot the data as an indicator, to proceed with the data in the other indicators, in the scripts for the automated analysis, in the Expert Advisors for the use in the trading strategies.
Embed MetaTrader 4/5 WebTerminal on your website for free and make a profit
Embed MetaTrader 4/5 WebTerminal on your website for free and make a profit

Embed MetaTrader 4/5 WebTerminal on your website for free and make a profit

Traders are well familiar with the WebTerminal, which allows trading on financial markets straight from the browser. Add the WebTerminal widget to your website — you can do it absolutely free. If you have a website, you can start selling leads to brokers — we have prepared a ready-to-use web-based solution for you. All you need to do is embed one iframe into your website.
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator

Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator

MetaQuotes Programming Language 5 (MQL5), included in MetaTrader 5 Client Terminal, has many new possibilities and higher performance, compared to MQL4. This article will help you to get acquainted with this new programming language. The simple examples of how to write an Expert Advisor and Custom Indicator are presented in this article. We will also consider some details of MQL5 language, that are necessary to understand these examples.
Create Your Own Trading Robot in 6 Steps!
Create Your Own Trading Robot in 6 Steps!

Create Your Own Trading Robot in 6 Steps!

If you don't know how trade classes are constructed, and are scared of the words "Object Oriented Programming", then this article is for you. In fact, you do not need to know the details to write your own module of trading signals. Just follow some simple rules. All the rest will be done by the MQL5 Wizard, and you will get a ready-to-use trading robot!
How to create Requirements Specification for ordering a trading robot
How to create Requirements Specification for ordering a trading robot

How to create Requirements Specification for ordering a trading robot

Are you trading using your own strategy? If your system rules can be formally described as software algorithms, it is better to entrust trading to an automated Expert Advisor. A robot does not need sleep or food and is not subject to human weaknesses. In this article, we show how to create Requirements Specification when ordering a trading robot in the Freelance service.
preview
How to Make a Trading Robot in No Time

How to Make a Trading Robot in No Time

Trading on financial markets involves many risks including the most critical one - the risk of making a wrong trading decision. The dream of every trader is to find a trading robot, which is always in good shape and not subject to human weaknesses - fear, greed and impatience.
Interview with Andrey Barinov (ATC 2012)
Interview with Andrey Barinov (ATC 2012)

Interview with Andrey Barinov (ATC 2012)

It was on Friday of the Championship's first week that the trading robot of Andrey Barinov (Wahoo) occupied the fifth place in TOP-10. Andrey is a newcomer in the Championship but he has already managed to execute more than 100 orders in Jobs and develop a dozen of products for Market. We have arranged an interview with him and learned that the development of a "simple multicurrency Expert Advisor" is not an easy but a fairly easy task.
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.
Using Self-Organizing Feature Maps (Kohonen Maps) in MetaTrader 5
Using Self-Organizing Feature Maps (Kohonen Maps) in MetaTrader 5

Using Self-Organizing Feature Maps (Kohonen Maps) in MetaTrader 5

One of the most interesting aspects of Self-Organizing Feature Maps (Kohonen maps) is that they learn to classify data without supervision. In its basic form it produces a similarity map of input data (clustering). The SOM maps can be used for classification and visualizing of high-dimensional data. In this article we will consider several simple applications of Kohonen maps.
preview
Orders, Positions and Deals in MetaTrader 5

Orders, Positions and Deals in MetaTrader 5

Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.
preview
Statistical Distributions in MQL5 - taking the best of R and making it faster

Statistical Distributions in MQL5 - taking the best of R and making it faster

The functions for working with the basic statistical distributions implemented in the R language are considered. Those include the Cauchy, Weibull, normal, log-normal, logistic, exponential, uniform, gamma distributions, the central and noncentral beta, chi-squared, Fisher's F-distribution, Student's t-distribution, as well as the discrete binomial and negative binomial distributions, geometric, hypergeometric and Poisson distributions. There are functions for calculating theoretical moments of distributions, which allow to evaluate the degree of conformity of the real distribution to the modeled one.
How to Order an Expert Advisor and Obtain the Desired Result
How to Order an Expert Advisor and Obtain the Desired Result

How to Order an Expert Advisor and Obtain the Desired Result

How to write correctly the Requirement Specifications? What should and should not be expected from a programmer when ordering an Expert Advisor or an indicator? How to keep a dialog, what moments to pay special attention to? This article gives the answers to these, as well as to many other questions, which often don't seem obvious to many people.
Testing trading strategies on real ticks
Testing trading strategies on real ticks

Testing trading strategies on real ticks

The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC", "Every tick" and "Every tick based on real ticks" using actual historical data.
MetaTrader 5 features hedging position accounting system
MetaTrader 5 features hedging position accounting system

MetaTrader 5 features hedging position accounting system

In order to expand possibilities of retail Forex traders, we have added the second accounting system — hedging. Now, it is possible to have multiple positions per symbol, including oppositely directed ones. This paves the way to implementing trading strategies based on the so-called "locking" — if the price moves against a trader, they can open a position in the opposite direction.
MetaTrader 5 and Python integration: receiving and sending data
MetaTrader 5 and Python integration: receiving and sending data

MetaTrader 5 and Python integration: receiving and sending data

Comprehensive data processing requires extensive tools and is often beyond the sandbox of one single application. Specialized programming languages are used for processing and analyzing data, statistics and machine learning. One of the leading programming languages for data processing is Python. The article provides a description of how to connect MetaTrader 5 and Python using sockets, as well as how to receive quotes via the terminal API.
Analyzing Candlestick Patterns
Analyzing Candlestick Patterns

Analyzing Candlestick Patterns

Construction of Japanese candlestick chart and analysis of candlestick patterns constitute an amazing area of technical analysis. The advantage of candlesticks is that they represent data in such a manner that you can track the dynamics inside the data. In this article we analyze candlestick types, classification of candlestick patterns and present an indicator that can determine candlestick patterns.
Securing MQL5 code: Password Protection, Key Generators, Time-limits, Remote Licenses and Advanced EA License Key Encryption Techniques
Securing MQL5 code: Password Protection, Key Generators, Time-limits, Remote Licenses and Advanced EA License Key Encryption Techniques

Securing MQL5 code: Password Protection, Key Generators, Time-limits, Remote Licenses and Advanced EA License Key Encryption Techniques

Most developers need to have their code secured. This article will present a few different ways to protect MQL5 software - it presents methods to provide licensing capabilities to MQL5 Scripts, Expert Advisors and Indicators. It covers password protection, key generators, account license, time-limit evaluation and remote protection using MQL5-RPC calls.
preview
The Fundamentals of Testing in MetaTrader 5

The Fundamentals of Testing in MetaTrader 5

What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market

The checks a trading robot must pass before publication in the Market

Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.