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
Object-Oriented Approach to Building Multi-Timeframe and Multi-Currency Panels
Object-Oriented Approach to Building Multi-Timeframe and Multi-Currency Panels

Object-Oriented Approach to Building Multi-Timeframe and Multi-Currency Panels

This article describes how object-oriented programming can be used for creating multi-timeframe and multi-currency panels for MetaTrader 5. The main goal is to build a universal panel, which can be used for displaying many different kinds of data, such as prices, price changes, indicator values or custom buy/sell conditions without the need to modify the code of the panel itself.
Interview with Andrea Zani (ATC 2011)
Interview with Andrea Zani (ATC 2011)

Interview with Andrea Zani (ATC 2011)

On the eleventh week of the Automated Trading Championship, Andrea Zani (sbraer) got featured very close to the top five of the competition. It is on the sixth place with about 47,000 USD now. Andrea's Expert Advisor AZXY has made only one losing deal, which was at the very beginning of the Championship. Since then, its equity curve has been steadily growing.
Interview with Li Fang (ATC 2011)
Interview with Li Fang (ATC 2011)

Interview with Li Fang (ATC 2011)

On the seventh week of the Championship, Li Fang's Expert Advisor (lf8749) set a new record - it earned over $100,000 in 10 trades. This successful series helped the Expert Advisor to stay at the very top of the Automated Trading Championship 2011 rating for two weeks. In this interview we tried to find out the secret of Li Fang's success.
Custom Graphical Controls. Part 2. Control Library
Custom Graphical Controls. Part 2. Control Library

Custom Graphical Controls. Part 2. Control Library

The second article of the "Custom Graphical Controls" series introduces a control library for handling the main problems arising in interaction between a program (Expert Advisor, script, indicator) and a user. The library contains a great number of classes (CInputBox, CSpinInputBox, CCheckBox, CRadioGroup, CVSсrollBar, CHSсrollBar, CList, CListMS, CComBox, CHMenu, CVMenu, CHProgress, CDialer, CDialerInputBox, CTable) and examples of their use.
MQL5-RPC. Remote Procedure Calls from MQL5: Web Service Access and XML-RPC ATC Analyzer for Fun and Profit
MQL5-RPC. Remote Procedure Calls from MQL5: Web Service Access and XML-RPC ATC Analyzer for Fun and Profit

MQL5-RPC. Remote Procedure Calls from MQL5: Web Service Access and XML-RPC ATC Analyzer for Fun and Profit

This article describes MQL5-RPC framework that enables Remote Procedure Calls from MQL5. It starts with XML-RPC basics, MQL5 implementation and follows with two real usage examples. First example is using external web service and the second one is a client to simple XML-RPC ATC 2011 Analyzer service. If you are interested on how to implement and analyze different statistics from ATC 2011 in real time, this article is just for you.
Interview with Valery Mazurenko (ATC 2011)
Interview with Valery Mazurenko (ATC 2011)

Interview with Valery Mazurenko (ATC 2011)

The task of writing an Expert Advisor trading on multiple currency pairs is complex both in terms of finding suitable strategies and from the technological side. But if the goal is set clear, nothing is impossible then. It was four times already that Vitaly Mazurenko (notused) submitted his multi-currency Expert Advisor. It seems, he has managed to find the right way this time.
The Basics of Object-Oriented Programming
The Basics of Object-Oriented Programming

The Basics of Object-Oriented Programming

You don't need to know what are polymorphism, encapsulation, etc. all about in to use object-oriented programming (OOP)... you may simply use these features. This article covers the basics of OOP with hands-on examples.
Interview with Andrey Bobryashov (ATC 2011)
Interview with Andrey Bobryashov (ATC 2011)

Interview with Andrey Bobryashov (ATC 2011)

Since the first Automated Trading Championship we have seen plenty of trading robots in our TOP-10 created with the use of various methods. Excellent results were shown both by the Exper Advisors based on standard indicators, and complicated analytical complexes with weekly automatic optimization of their own parameters.
Interview with Vitaly Antonov (ATC 2011)
Interview with Vitaly Antonov (ATC 2011)

Interview with Vitaly Antonov (ATC 2011)

It was only this summer that Vitaly Antonov (beast) has learned about the upcoming Automated Trading Championship and got to know MetaTrader 5 terminal. Time was running out, besides, Vitaly was a newcomer. So, he randomly chose GBPUSD currency pair to develop his trading system. And the choice turned out to be successful. It would have been impossible to use other symbols with the strategy.
Statistical Probability Distributions in MQL5
Statistical Probability Distributions in MQL5

Statistical Probability Distributions in MQL5

The article addresses probability distributions (normal, log-normal, binomial, logistic, exponential, Cauchy distribution, Student's t-distribution, Laplace distribution, Poisson distribution, Hyperbolic Secant distribution, Beta and Gamma distribution) of random variables used in Applied Statistics. It also features classes for handling these distributions.
Interview with Dr. Alexander Elder: "I want to be a psychiatrist in the market"
Interview with Dr. Alexander Elder: "I want to be a psychiatrist in the market"

Interview with Dr. Alexander Elder: "I want to be a psychiatrist in the market"

I think financial markets are like manic-depressive patients. Sell when they have mania, and buy when they have depression. The envelope helps me determine where these levels of depression and mania are. There is a joke: "A neurotic is a man who builds castles in the skies, psychotic is the one who lives in them, and a psychiatrist is a person who collects the rent." I want to be a psychiatrist in the market. I want to collect the rent from the madness of the crowd.
Testing (Optimization) Technique and Some Criteria for Selection of the Expert Advisor Parameters
Testing (Optimization) Technique and Some Criteria for Selection of the Expert Advisor Parameters

Testing (Optimization) Technique and Some Criteria for Selection of the Expert Advisor Parameters

There is no trouble finding the Holy Grail of testing, it is however much more difficult to get rid of it. This article addresses the selection of the Expert Advisor operating parameters with automated group processing of optimisation and testing results upon maximum utilisation of the Terminal performance capabilities and minimum end user load.
ATC Champions League: Interview with Boris Odintsov (ATC 2011)
ATC Champions League: Interview with Boris Odintsov (ATC 2011)

ATC Champions League: Interview with Boris Odintsov (ATC 2011)

Interview with Boris Odintsov (bobsley) is the last one within the ATC Champions League project. Boris won the Automated Trading Championship 2010 - the first Championship held for the Expert Advisors in the new MQL5 language. Having appeared in the top ten already in the first week of the ATC 2010, his EA brought it to the finish and earned $77,000. This year, Boris participates in the competition with the same Expert Advisor with modified settings. Perhaps the robot would still be able to repeat its success.
Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor
Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor

Dr. Tradelove or How I Stopped Worrying and Created a Self-Training Expert Advisor

Just over a year ago joo, in his article "Genetic Algorithms - It's Easy!", gave us a tool for implementation of the genetic algorithm in MQL5. Now utilizing the tool we will create an Expert Advisor that will genetically optimize its own parameters upon certain boundary conditions...
Interview with Ge Senlin (ATC 2011)
Interview with Ge Senlin (ATC 2011)

Interview with Ge Senlin (ATC 2011)

The Expert Advisor by Ge Senlin (yyy999) from China got featured in the top ten of the Automated Trading Championship 2011 in late October and hasn't left it since then. Not often participants from the PRC show good results in the Championship - Forex trading is not allowed in this country. After the poor results in the previous year ATC, Senlin has prepared a new multicurrency Expert Advisor that never closes loss positions and uses position increase instead. Let's see whether this EA will be able to rise even higher with such a risky strategy.
Using MetaTrader 5 as a Signal Provider for MetaTrader 4
Using MetaTrader 5 as a Signal Provider for MetaTrader 4

Using MetaTrader 5 as a Signal Provider for MetaTrader 4

Analyse and examples of techniques how trading analysis can be performed on MetaTrader 5 platform, but executed by MetaTrader 4. Article will show you how to create simple signal provider in your MetaTrader 5, and connect to it with multiple clients, even running MetaTrader 4. Also you will find out how you can follow participants of Automated Trading Championship in your real MetaTrader 4 account.
Interview with Ilnur Khasanov (ATC 2011)
Interview with Ilnur Khasanov (ATC 2011)

Interview with Ilnur Khasanov (ATC 2011)

The Expert Advisor of Ilnur Khasanov (aharata) is holding its place in our TOP-10 chart of the Automated Trading Championship 2011 participants from the third week already, though Ilnur's acquaintance with Forex has started only a year ago. The idea that forms the basis of the Expert Advisor is simple but the trading robot contains self-optimization elements. Perhaps, that is the key to its survival? Besides, the author had to change the Expert Advisor planned to be submitted for the Championship...
Interview with Igor Korepin (ATC 2011)
Interview with Igor Korepin (ATC 2011)

Interview with Igor Korepin (ATC 2011)

Appearance of the Expert Advisor cs2011 by Igor Korepin (Xupypr) at the very top of the Automated Trading Championship 2011 was really impressive - its balance was almost twice that of the EA featured on the second place. However, despite such a sound breakaway, the Expert Advisor could not stay long on the first line. Igor frankly said that he relied much on a lucky start of his trading robot in the competition. We'll see if luck helps this simple EA to take the lead in the ATC 2011 race again.
Creating MQL5 Expert Advisors in minutes using EA Tree: Part One
Creating MQL5 Expert Advisors in minutes using EA Tree: Part One

Creating MQL5 Expert Advisors in minutes using EA Tree: Part One

EA Tree is the first drag and drop MetaTrader MQL5 Expert Advisor builder. You can create complex MQL5 using a very easy to use graphical user interface. In EA Tree, Expert Advisors are created by connecting boxes together. Boxes may contain MQL5 functions, technical indicators, custom indicators, or values. Using the "tree of boxes", EA Tree generates the MQL5 code of the Expert Advisor.
Interview with Tim Fass (ATC 2011)
Interview with Tim Fass (ATC 2011)

Interview with Tim Fass (ATC 2011)

A student from Germany Tim Fass (Tim) is participating in the Automated Trading Championship for the first time. Nevertheless, his Expert Advisor The_Wild_13 already got featured at the very top of the Championship rating and seems to be holding his position in the top ten. Tim told us about his Expert Advisor, his faith in the success of simple strategies and his wildest dreams.
ATC Champions League: Interview with Olexandr Topchylo (ATC 2011)
ATC Champions League: Interview with Olexandr Topchylo (ATC 2011)

ATC Champions League: Interview with Olexandr Topchylo (ATC 2011)

Interview with Olexandr Topchylo (Better) is the second publication within the "ATC Champions League" project. Having won the Automated Trading Championship 2007, this professional trader caught the attention of investors. Olexandr says that his first place in the ATC 2007 is one of the major events of his trading experience. However, later on this popularity helped him discover the biggest disappointment - it is so easy to lose investors after the first drawdown on an investor account.
Interview with Atsushi Yamanaka (ATC 2011)
Interview with Atsushi Yamanaka (ATC 2011)

Interview with Atsushi Yamanaka (ATC 2011)

What is common between skydiving, Futures, Hawaii, translations and spies? We didn't know it until we've managed to communicate with disqualified participant Atsushi Yamanaka (alohafx). His has a creed "Life is Good!", and one can hardly doubt that. It was interesting to know that distances between the continents are not an obstacle for communication among our Championship's participants.
Interview with Andrei Moraru (ATC 2011)
Interview with Andrei Moraru (ATC 2011)

Interview with Andrei Moraru (ATC 2011)

Ukrainian programmer Andrei Moraru (enivid) is an active participant of the Automated Trading Championship beginning from 2007. Andrei had already come in our view at that time and now we have decided to find out if there occured any changes in his attitude towards trading and selection of trading strategies for the past four years, and also to know about his new Expert Advisor.
Interview with Sergey Nikitin (ATC 2011)
Interview with Sergey Nikitin (ATC 2011)

Interview with Sergey Nikitin (ATC 2011)

In the second week of the competition, the Expert Advisor of Sergey Nikitin (VNIK) trading on two currency pairs EURUSD and EURJPY got featured on the very top drawing away from the rest. Multicurrency Expert Advisors always attract attention in the Championship, especially those that show good results. We talked with Sergey about the role of luck in a trader's life and his way of trading.
ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)
ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)

ATC Champions League: Interview with Roman Zamozhniy (ATC 2011)

This is the first interview in the "ATC Champions League" project. Roman Zamozhniy (Rich) from Ukraine was the winner of the first Automated Trading Championship in 2006. In addition, he is a regular participant of our Championships - he has not missed a single contest. In this interview, we talked about Roman's first place and tried to figure out what is necessary for successful participation.
Interview with Antonio Morillas (ATC 2011)
Interview with Antonio Morillas (ATC 2011)

Interview with Antonio Morillas (ATC 2011)

Antonio Morillas from Spain (sallirom, by the way - it is reversed surname!) was first who doubled his starting balance from the beginning of the Championship and thus attracted our attention. His trading strategy is extremely risky. We decided to talk to Antonio about risk and luck as these are part and parcel of Automated Trading Championship.
Interview with Matúš German (ATC 2011)
Interview with Matúš German (ATC 2011)

Interview with Matúš German (ATC 2011)

On the second day of the Championship the Expert Advisor created by Matúš German (gery18) increased its capital by 2.5 times and took the lead being ahead of all competitors. Matúš himself doubts his Expert Advisor will win, he thinks that luck and high risk were the reasons of such unexpected rise.
Custom Graphical Controls. Part 1: Creating a Simple Control
Custom Graphical Controls. Part 1: Creating a Simple Control

Custom Graphical Controls. Part 1: Creating a Simple Control

This article covers general principles of development of graphical controls. We are going to prepare tools for a quick and convenient work with graphical objects, analyze an example of creation of a simple control for entering text or numeric data as well as the ways of using it.
Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"
Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"

Nikolay Ivanov (Techno): "What is important for programs is the accuracy of their algorithms"

A programmer from Krasnoyarsk Nikolay Ivanov (Techno) is a leader among the developers in terms of the number of completed orders - he has implemented already more than 200 applications in the Jobs service. In this interview, he is talking about the Jobs service, its specific features and challengers faced by programmers.
Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"
Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"

Andrey Bolkonsky (abolk): "Any programmer knows that there is no software without bugs"

Andrey Bolkonsky (abolk) has been participating in the Jobs service since its opening. He has developed dozens of indicators and Expert Advisors for the MetaTrader 4 and MetaTrader 5 platforms. We will talk with Andrey about what a server is from the perspective of a programmer.
Andrey Voitenko (avoitenko): "Developers benefit from the ideas that they code? Nonsense!"
Andrey Voitenko (avoitenko): "Developers benefit from the ideas that they code? Nonsense!"

Andrey Voitenko (avoitenko): "Developers benefit from the ideas that they code? Nonsense!"

A Ukrainian developer Andrey Voitenko (avoitenko) is an active participant of the "Jobs" service at mql5.com, helping traders from all over the world to implement their ideas. Last year Andrey's Expert Advisor was on the fourth place in the Automated Trading Championship 2010, being slightly behind the bronze winner. This time we are discussing the Jobs service with Andrey.
Creating Custom Criteria of Optimization of Expert Advisors
Creating Custom Criteria of Optimization of Expert Advisors

Creating Custom Criteria of Optimization of Expert Advisors

The MetaTrader 5 Client Terminal offers a wide range of opportunities for optimization of Expert Advisor parameters. In addition to the optimization criteria included in the strategy tester, developers are given the opportunity of creating their own criteria. This leads to an almost limitless number of possibilities of testing and optimizing of Expert Advisors. The article describes practical ways of creating such criteria - both complex and simple ones.
Applying The Fisher Transform and Inverse Fisher Transform to Markets Analysis in MetaTrader 5
Applying The Fisher Transform and Inverse Fisher Transform to Markets Analysis in MetaTrader 5

Applying The Fisher Transform and Inverse Fisher Transform to Markets Analysis in MetaTrader 5

We now know that probability density function (PDF) of a market cycle does not remind a Gaussian but rather a PDF of a sine wave and most of the indicators assume that the market cycle PDF is Gaussian we need a way to "correct" that. The solution is to use Fisher Transform. The Fisher transform changes PDF of any waveform to approximately Gaussian. This article describes the mathematics behind the Fisher Transform and the Inverse Fisher Transform and their application to trading. A proprietary trading signal module based on the Inverse Fisher Transform is presented and evaluated.
3 Methods of Indicators Acceleration by the Example of the Linear Regression
3 Methods of Indicators Acceleration by the Example of the Linear Regression

3 Methods of Indicators Acceleration by the Example of the Linear Regression

The article deals with the methods of indicators computational algorithms optimization. Everyone will find a method that suits his/her needs best. Three methods are described here.One of them is quite simple, the next one requires solid knowledge of Math and the last one requires some wit. Indicators or MetaTrader5 terminal design features are used to realize most of the described methods. The methods are quite universal and can be used not only for acceleration of the linear regression calculation, but also for many other 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

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.
Enhancing the Quality of the Code with the Help of Unit Test
Enhancing the Quality of the Code with the Help of Unit Test

Enhancing the Quality of the Code with the Help of Unit Test

Even simple programs may often have errors that seem to be unbelievable. "How could I create that?" is our first thought when such an error is revealed. "How can I avoid that?" is the second question which comes to our mind less frequently. It is impossible to create absolutely faultless code, especially in big projects, but it is possible to use technologies for their timely detection. The article describes how the MQL4 code quality can be enhanced with the help of the popular Unit Testing method.
The Player of Trading Based on Deal History
The Player of Trading Based on Deal History

The Player of Trading Based on Deal History

The player of trading. Only four words, no explanation is needed. Thoughts about a small box with buttons come to your mind. Press one button - it plays, move the lever - the playback speed changes. In reality, it is pretty similar. In this article, I want to show my development that plays trade history almost like it is in real time. The article covers some nuances of OOP, working with indicators and managing charts.
How to Add New UI Languages to the MetaTrader 5 Platform
How to Add New UI Languages to the MetaTrader 5 Platform

How to Add New UI Languages to the MetaTrader 5 Platform

User interface of the MetaTrader 5 platform is translated into several languages. Don't worry if your native language is not among the supported ones. You can easily complete the translation using the special MetaTrader 5 MultiLanguage Pack utility, offered by MetaQuotes Software Corp. for free to all comers. In this article we will show some examples of how to add a new user interface languages to the MetaTrader 5 platform.
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.
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.