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
MQL5 Wizard: Placing Orders, Stop-Losses and Take Profits on Calculated Prices. Standard Library Extension
MQL5 Wizard: Placing Orders, Stop-Losses and Take Profits on Calculated Prices. Standard Library Extension

MQL5 Wizard: Placing Orders, Stop-Losses and Take Profits on Calculated Prices. Standard Library Extension

This article describes the MQL5 Standard Library extension, which allows to create Expert Advisors, place orders, Stop Losses and Take Profits using the MQL5 Wizard by the prices received from included modules. This approach does not apply any additional restrictions on the number of modules and does not cause conflicts in their joint work.
Liquid Chart
Liquid Chart

Liquid Chart

Would you like to see an hourly chart with bars opening from the second and the fifth minute of the hour? What does a redrawn chart look like when the opening time of bars is changing every minute? What advantages does trading on such charts have? You will find answers to these questions in this article.
MQL5 Programming Basics: Global Variables of the Terminal
MQL5 Programming Basics: Global Variables of the Terminal

MQL5 Programming Basics: Global Variables of the Terminal

This article highlights object-oriented capabilities of the MQL5 language for creating objects facilitating work with global variables of the terminal. As a practical example I consider a case when global variables are used as control points for implementation of program stages.
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 Cookbook: Handling BookEvent
MQL5 Cookbook: Handling BookEvent

MQL5 Cookbook: Handling BookEvent

This article considers BookEvent - a Depth of Market event, and the principle of its processing. An MQL program, handling states of Depth of Market, serves as an example. It is written using the object-oriented approach. Results of handling are displayed on the screen as a panel and Depth of Market levels.
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.
MQL5 Cookbook: Handling Custom Chart Events
MQL5 Cookbook: Handling Custom Chart Events

MQL5 Cookbook: Handling Custom Chart Events

This article considers aspects of design and development of custom chart events system in the MQL5 environment. An example of an approach to the events classification can also be found here, as well as a program code for a class of events and a class of custom events handler.
MQL5 Cookbook: Handling Typical Chart Events
MQL5 Cookbook: Handling Typical Chart Events

MQL5 Cookbook: Handling Typical Chart Events

This article considers typical chart events and includes examples of their processing. We will focus on mouse events, keystrokes, creation/modification/removal of a graphical object, mouse click on a chart and on a graphical object, moving a graphical object with a mouse, finish editing of text in a text field, as well as on chart modification events. A sample of an MQL5 program is provided for each type of event considered.
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.
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.
Regression Analysis of the Influence of Macroeconomic Data on Currency Prices Fluctuation
Regression Analysis of the Influence of Macroeconomic Data on Currency Prices Fluctuation

Regression Analysis of the Influence of Macroeconomic Data on Currency Prices Fluctuation

This article considers the application of multiple regression analysis to macroeconomic statistics. It also gives an insight into the evaluation of the statistics impact on the currency exchange rate fluctuation based on the example of the currency pair EURUSD. Such evaluation allows automating the fundamental analysis which becomes available to even novice traders.
Indicator for Constructing a Three Line Break Chart
Indicator for Constructing a Three Line Break Chart

Indicator for Constructing a Three Line Break Chart

This article is dedicated to the Three Line Break chart, suggested by Steve Nison in his book "Beyond Candlesticks". The greatest advantage of this chart is that it allows filtering minor fluctuations of a price in relation to the previous movement. We are going to discuss the principle of the chart construction, the code of the indicator and some examples of trading strategies based on it.
How we developed the MetaTrader Signals service and Social Trading
How we developed the MetaTrader Signals service and Social Trading

How we developed the MetaTrader Signals service and Social Trading

We continue to enhance the Signals service, improve the mechanisms, add new functions and fix flaws. The MetaTrader Signals Service of 2012 and the current MetaTrader Signals Service are like two completely different services. Currently, we are implementing A Virtual Hosting Cloud service which consists of a network of servers to support specific versions of the MetaTrader client terminal. Traders will need to complete only 5 steps in order to rent the virtual copy of their terminal with minimal network latency to their broker's trade server directly from the MetaTrader client terminal.
How we developed the MetaTrader Signals service and Social Trading
How we developed the MetaTrader Signals service and Social Trading

How we developed the MetaTrader Signals service and Social Trading

We continue to enhance the Signals service, improve the mechanisms, add new functions and fix flaws. The MetaTrader Signals Service of 2012 and the current MetaTrader Signals Service are like two completely different services. Currently, we are implementing A Virtual Hosting Cloud service which consists of a network of servers to support specific versions of the MetaTrader client terminal.
MQL5 Cookbook - Multi-Currency Expert Advisor and Working with Pending Orders in MQL5
MQL5 Cookbook - Multi-Currency Expert Advisor and Working with Pending Orders in MQL5

MQL5 Cookbook - Multi-Currency Expert Advisor and Working with Pending Orders in MQL5

This time we are going to create a multi-currency Expert Advisor with a trading algorithm based on work with the pending orders Buy Stop and Sell Stop. This article considers the following matters: trading in a specified time range, placing/modifying/deleting pending orders, checking if the last position was closed at Take Profit or Stop Loss and control of the deals history for each symbol.
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.
Freelance Jobs on MQL5.com - Developer's Favorite Place
Freelance Jobs on MQL5.com - Developer's Favorite Place

Freelance Jobs on MQL5.com - Developer's Favorite Place

Developers of trading robots no longer need to market their services to traders that require Expert Advisors - as now they will find you. Already, thousands of traders place orders to MQL5 freelance developers, and pay for work in on MQL5.com. For 4 years, this service facilitated three thousand traders to pay for more than 10 000 jobs performed. And the activity of traders and developers is constantly growing!
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.
Outline of MetaTrader Market (Infographics)
Outline of MetaTrader Market (Infographics)

Outline of MetaTrader Market (Infographics)

A few weeks ago we published the infographic on Freelance service. We also promised to reveal some statistics of the MetaTrader Market. Now, we invite you to examine the data we have gathered.
Johnpaul77 Signal Providers: "Our Strategy Remains Profitable for More Than Three Years Now. So Why Would We Change It?"
Johnpaul77 Signal Providers: "Our Strategy Remains Profitable for More Than Three Years Now. So Why Would We Change It?"

Johnpaul77 Signal Providers: "Our Strategy Remains Profitable for More Than Three Years Now. So Why Would We Change It?"

Let us reveal a little secret: MQL5.com website visitors spend most of their time on Johnpaul77 signal's page. It is a leader of our signal rating having about 900 subscribers with the total funds of $5.7 million on real accounts. We have interviewed the signal's providers. As it turned out, there are four of them! How are duties distributed among the team members? What technical tools do they use? Why do they call themselves John Paul? And finally, how have common gamers from Indonesia become providers of the top signal on MQL5.com? Find out all that in the article.
MQL5.com Freelance: Developers' Source of Income (Infographic)
MQL5.com Freelance: Developers' Source of Income (Infographic)

MQL5.com Freelance: Developers' Source of Income (Infographic)

On the occasion of the MQL5 Freelance Service fourth birthday, we have prepared an info-graphic demonstrating the service results for the entire time of its existence. The figures speak for themselves: more than 10 000 orders worth about $600,000 in total have been executed to date, while 3 000 customers and 300 developers have already used the service.
How to implement traders' orders and make a profit in the MQL5 Freelance service
How to implement traders' orders and make a profit in the MQL5 Freelance service

How to implement traders' orders and make a profit in the MQL5 Freelance service

MQL5 Freelance is an online service where developers get paid for creating trading applications ordered by traders. Now, traders understand the difference between all the services on MQL5.com: a ready-made Trading Robot can be bought from the MetaTrader Market, while a unique Expert Advisor that trades based on a specific user-defined strategy can be ordered in the Freelance service. Experienced developers compete for traders' order implementation, so that a trader can select the one who offers the best time and cost conditions. Since the launch of the service, traders have paid a total of $600,000 for 10,000 jobs performed
Do Traders Need Services From Developers?
Do Traders Need Services From Developers?

Do Traders Need Services From Developers?

Algorithmic trading becomes more popular and needed, which naturally led to a demand for exotic algorithms and unusual tasks. To some extent, such complex applications are available in the Code Base or in the Market. Although traders have simple access to those apps in a couple of clicks, these apps may not satisfy all needs in full. In this case, traders look for developers who can write a desired application in the MQL5 Freelance section and assign an order.
Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals
Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals

Building a Social Technology Startup, Part I: Tweet Your MetaTrader 5 Signals

Today we will learn how to link an MetaTrader 5 terminal with Twitter so that you can tweet your EAs' trading signals. We are developing a Social Decision Support System in PHP based on a RESTful web service. This idea comes from a particular conception of automatic trading called computer-assisted trading. We want the cognitive abilities of human traders to filter those trading signals which otherwise would be automatically placed on the market by the Expert Advisors.
Indicator for Renko charting
Indicator for Renko charting

Indicator for Renko charting

The article describes an example of Renko charting and its implementation in MQL5 as an indicator. Modifications of this indicator distinguish it from a classic chart. It can be constructed both in the indicator window and on the main chart. Moreover, there is the ZigZag indicator. You can find a few examples of the chart implementation.
Continuous futures contracts in MetaTrader 5
Continuous futures contracts in MetaTrader 5

Continuous futures contracts in MetaTrader 5

A short life span of futures contracts complicates their technical analysis. It is difficult to technically analyze short charts. For example, number of bars on the day chart of the UX-9.13 Ukrainian Stock index future is more than 100. Therefore, trader creates synthetic long futures contracts. This article explains how to splice futures contracts with different dates in the MetaTrader 5 terminal.
Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?
Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?

Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?

From August 1, 2014, MetaTrader 4 desktop terminals older than build 600 will no longer be supported. However, many traders still work with outdated versions and are unaware of the updated platform's features. We have put a lot of effort into development and would like to move on with traders and abandon the older builds. In this article, we will describe the advantages of the new MetaTrader 4.
MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence
MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence

MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence

In this article, we will consider the development of a multi-symbol indicator to analyze price divergence in a specified period of time. The core topics have been already discussed in the previous article on the programming of multi-currency indicators "MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5". So this time we will dwell only on those new features and functions that have been changed dramatically. If you are new to the programming of multi-currency indicators, I recommend you to first read the previous article.
Tales of Trading Robots: Is Less More?
Tales of Trading Robots: Is Less More?

Tales of Trading Robots: Is Less More?

Two years ago in "The Last Crusade" we reviewed quite an interesting yet currently not widely used method for displaying market information - point and figure charts. Now I suggest you try to write a trading robot based on the patterns detected on the point and figure chart.
SQL and MQL5: Working with SQLite Database
SQL and MQL5: Working with SQLite Database

SQL and MQL5: Working with SQLite Database

This article is intended for developers who would be interested in using SQL in their projects. It explains the functionality and advantages of SQLite. The article does not require special knowledge of SQLite functions, yet minimum understanding of SQL would be beneficial.
Common Errors in MQL4 Programs and How to Avoid Them
Common Errors in MQL4 Programs and How to Avoid Them

Common Errors in MQL4 Programs and How to Avoid Them

To avoid critical completion of programs, the previous version compiler handled many errors in the runtime environment. For example, division by zero or array out of range are critical errors and usually lead to program crash. The new compiler can detect actual or potential sources of errors and improve code quality. In this article, we discuss possible errors that can be detected during compilation of old programs and see how to fix them.
Upgrade to MetaTrader 4 Build 600 and Higher
Upgrade to MetaTrader 4 Build 600 and Higher

Upgrade to MetaTrader 4 Build 600 and Higher

The new version of the MetaTrader 4 terminal features the updated structure of user data storage. In earlier versions all programs, templates, profiles etc. were stored directly in terminal installation folder. Now all necessary data required for a particular user are stored in a separate directory called data folder. Read the article to find answers to frequently asked questions.
Working with GSM Modem from an MQL5 Expert Advisor
Working with GSM Modem from an MQL5 Expert Advisor

Working with GSM Modem from an MQL5 Expert Advisor

There is currently a fair number of means for a comfortable remote monitoring of a trading account: mobile terminals, push notifications, working with ICQ. But it all requires Internet connection. This article describes the process of creating an Expert Advisor that will allow you to stay in touch with your trading terminal even when mobile Internet is not available, through calls and text messaging.
MQL5 Programming Basics: Lists
MQL5 Programming Basics: Lists

MQL5 Programming Basics: Lists

The new version of the programming language for trading strategy development, MQL [MQL5], provides more powerful and effective features as compared with the previous version [MQL4]. The advantage essentially lies in the object-oriented programming features. This article looks into the possibility of using complex custom data types, such as nodes and lists. It also provides an example of using lists in practical programming in MQL5.
Data Structure in MetaTrader 4 Build 600 and Higher
Data Structure in MetaTrader 4 Build 600 and Higher

Data Structure in MetaTrader 4 Build 600 and Higher

MetaTarder 4 build 600 features the new structure and location of the client terminal files. Now, MQL4 applications are placed in separate directories according to the program type (Expert Advisors, indicators or scripts). In most cases, the terminal data is now stored in a special data folder separated from the terminal installation location. In this article, we will describe in details how data is transferred, as well as the reasons for introducing the new storage system.
Offline Charts in the New MQL4
Offline Charts in the New MQL4

Offline Charts in the New MQL4

Updated MQL4 has the new format for storing historical data and provides the appropriate MqlRates structure for convenient storage of Time, Open, Low, High, Close and Volume values. For many years, traders have developed their MQL4 applications that collect and store their data in HST files for generating offline charts. We can assure you that all previously compiled EX4 files will work in the new MetaTrader 4 terminal the same way as before.
Creating Non-Lagging Digital Filters
Creating Non-Lagging Digital Filters

Creating Non-Lagging Digital Filters

The article describes one of the approaches to determining a useful signal (trend) in stream data. Small filtering (smoothing) tests applied to market quotes demonstrate the potential for creating non-lagging digital filters (indicators) that are not redrawn on the last bars.
MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5
MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5

MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5

In this article, we will consider the development of a multi-symbol volatility indicator. The development of multi-symbol indicators may present some difficulties for novice MQL5 developers which this article helps to clarify. The major issues arising in the course of development of a multi-symbol indicator have to do with the synchronization of other symbols' data with respect to the current symbol, the lack of some indicator data and the identification of the beginning of 'true' bars of a given time frame. All of these issues will be closely considered in the article.
Indicator for Kagi Charting
Indicator for Kagi Charting

Indicator for Kagi Charting

The article proposes Kagi chart indicator with various charting options and additional functions. Also, indicator charting principle and its MQL5 implementation features are considered. The most popular cases of its implementation in trading are displayed - Yin/Yang exchange strategy, pushing away from the trend line and consistently increasing "shoulders"/decreasing "waists".
Creating a Multi-Currency Multi-System Expert Advisor
Creating a Multi-Currency Multi-System Expert Advisor

Creating a Multi-Currency Multi-System Expert Advisor

The article introduces a structure for an Expert Advisor that trades multiple symbols and uses several trading systems simultaneously. If you already identified the optimal input parameters for all your EAs and got good backtesting results for each of them separately, ask yourself what results you would get if testing all EAs simultaneously, with all your strategies put together.