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
Who Is Who in MQL5.community?
Who Is Who in MQL5.community?

Who Is Who in MQL5.community?

The MQL5.com website remembers all of you quite well! How many of your threads are epic, how popular your articles are and how often your programs in the Code Base are downloaded – this is only a small part of what is remembered at MQL5.com. Your achievements are available in your profile, but what about the overall picture? In this article we will show the general picture of all MQL5.community members achievements.
Getting Rid of Self-Made DLLs
Getting Rid of Self-Made DLLs

Getting Rid of Self-Made DLLs

If MQL5 language functional is not enough for fulfilling tasks, an MQL5 programmer has to use additional tools. He\she has to pass to another programming language and create an intermediate DLL. MQL5 has the possibility to present various data types and transfer them to API but, unfortunately, MQL5 cannot solve the issue concerning data extraction from the accepted pointer. In this article we will dot all the "i"s and show simple mechanisms of exchanging and working with complex data types.
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.
How to Develop an Expert Advisor using UML Tools
How to Develop an Expert Advisor using UML Tools

How to Develop an Expert Advisor using UML Tools

This article discusses creation of Expert Advisors using the UML graphical language, which is used for visual modeling of object-oriented software systems. The main advantage of this approach is the visualization of the modeling process. The article contains an example that shows modeling of the structure and properties of an Expert Advisor using the Software Ideas Modeler.
The Last Crusade
The Last Crusade

The Last Crusade

Take a look at your trading terminal. What means of price presentation can you see? Bars, candlesticks, lines. We are chasing time and prices whereas we only profit from prices. Shall we only give attention to prices when analyzing the market? This article proposes an algorithm and a script for point and figure charting ("naughts and crosses") Consideration is given to various price patterns whose practical use is outlined in recommendations provided.
Analyzing the Indicators Statistical Parameters
Analyzing the Indicators Statistical Parameters

Analyzing the Indicators Statistical Parameters

The technical analysis widely implements the indicators showing the basic quotes "more clearly" and allowing traders to perform analysis and forecast market prices movement. It's quite obvious that there is no sense in using the indicators, let alone applying them in creation of trading systems, unless we can solve the issues concerning initial quotes transformation and the obtained result credibility. In this article we show that there are serious reasons for such a conclusion.
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!
The Box-Cox Transformation
The Box-Cox Transformation

The Box-Cox Transformation

The article is intended to get its readers acquainted with the Box-Cox transformation. The issues concerning its usage are addressed and some examples are given allowing to evaluate the transformation efficiency with random sequences and real quotes.
Simple Trading Systems Using Semaphore Indicators
Simple Trading Systems Using Semaphore Indicators

Simple Trading Systems Using Semaphore Indicators

If we thoroughly examine any complex trading system, we will see that it is based on a set of simple trading signals. Therefore, there is no need for novice developers to start writing complex algorithms immediately. This article provides an example of a trading system that uses semaphore indicators to perform deals.
Multiple Regression Analysis. Strategy Generator and Tester in One
Multiple Regression Analysis. Strategy Generator and Tester in One

Multiple Regression Analysis. Strategy Generator and Tester in One

The article gives a description of ways of use of the multiple regression analysis for development of trading systems. It demonstrates the use of the regression analysis for strategy search automation. A regression equation generated and integrated in an EA without requiring high proficiency in programming is given as an example.
Time Series Forecasting Using Exponential Smoothing (continued)
Time Series Forecasting Using Exponential Smoothing (continued)

Time Series Forecasting Using Exponential Smoothing (continued)

This article seeks to upgrade the indicator created earlier on and briefly deals with a method for estimating forecast confidence intervals using bootstrapping and quantiles. As a result, we will get the forecast indicator and scripts to be used for estimation of the forecast accuracy.
Trademinator 3: Rise of the Trading Machines
Trademinator 3: Rise of the Trading Machines

Trademinator 3: Rise of the Trading Machines

In the article "Dr. Tradelove..." we created an Expert Advisor, which independently optimizes parameters of a pre-selected trading system. Moreover, we decided to create an Expert Advisor that can not only optimize parameters of one trading system underlying the EA, but also select the best one of several trading systems. Let's see what can come of it...
Promote Your Development Projects Using EX5 Libraries
Promote Your Development Projects Using EX5 Libraries

Promote Your Development Projects Using EX5 Libraries

Hiding of the implementation details of classes/functions in an .ex5 file will enable you to share your know-how algorithms with other developers, set up common projects and promote them in the Web. And while the MetaQuotes team spares no effort to bring about the possibility of direct inheritance of ex5 library classes, we are going to implement it right now.
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.
The All or Nothing Forex Strategy
The All or Nothing Forex Strategy

The All or Nothing Forex Strategy

The purpose of this article is to create the most simple trading strategy that implements the "All or Nothing" gaming principle. We don't want to create a profitable Expert Advisor - the goal is to increase the initial deposit several times with the highest possible probability. Is it possible to hit the jackpot on ForEx or lose everything without knowing anything about technical analysis and without using any indicators?
Using Discriminant Analysis to Develop Trading Systems
Using Discriminant Analysis to Develop Trading Systems

Using Discriminant Analysis to Develop Trading Systems

When developing a trading system, there usually arises a problem of selecting the best combination of indicators and their signals. Discriminant analysis is one of the methods to find such combinations. The article gives an example of developing an EA for market data collection and illustrates the use of the discriminant analysis for building prognostic models for the FOREX market in Statistica software.
Speed Up Calculations with the MQL5 Cloud Network
Speed Up Calculations with the MQL5 Cloud Network

Speed Up Calculations with the MQL5 Cloud Network

How many cores do you have on your home computer? How many computers can you use to optimize a trading strategy? We show here how to use the MQL5 Cloud Network to accelerate calculations by receiving the computing power across the globe with the click of a mouse. The phrase "Time is money" becomes even more topical with each passing year, and we cannot afford to wait for important computations for tens of hours or even days.
Create Your Own Graphical Panels in MQL5
Create Your Own Graphical Panels in MQL5

Create Your Own Graphical Panels in MQL5

The MQL5 program usability is determined by both its rich functionality and an elaborate graphical user interface. Visual perception is sometimes more important than fast and stable operation. Here is a step-by-step guide to creating display panels on the basis of the Standard Library classes on your own.
Time Series Forecasting Using Exponential Smoothing
Time Series Forecasting Using Exponential Smoothing

Time Series Forecasting Using Exponential Smoothing

The article familiarizes the reader with exponential smoothing models used for short-term forecasting of time series. In addition, it touches upon the issues related to optimization and estimation of the forecast results and provides a few examples of scripts and indicators. This article will be useful as a first acquaintance with principles of forecasting on the basis of exponential smoothing models.
Interview with Alexander Arashkevich (ATC 2011)
Interview with Alexander Arashkevich (ATC 2011)

Interview with Alexander Arashkevich (ATC 2011)

The Championship fervour has finally subsided and we can take a breath and start rethinking its results again. And we have another winner Alexander Arashkevich (AAA777) from Belarus, who has won a special prize from the major sponsor of Automated Trading Championship 2011 - a 3 day trip to one of the Formula One races of the 2012 season. We could not miss the opportunity to talk with him.
Analysis of the Main Characteristics of Time Series
Analysis of the Main Characteristics of Time Series

Analysis of the Main Characteristics of Time Series

This article introduces a class designed to give a quick preliminary estimate of characteristics of various time series. As this takes place, statistical parameters and autocorrelation function are estimated, a spectral estimation of time series is carried out and a histogram is built.
Creating Expert Advisors Using Expert Advisor Visual Wizard
Creating Expert Advisors Using Expert Advisor Visual Wizard

Creating Expert Advisors Using Expert Advisor Visual Wizard

Expert Advisor Visual Wizard for MetaTrader 5 provides a highly intuitive graphical environment with a comprehensive set of predefined trading blocks that let you design Expert Advisors in minutes. The click, drag and drop approach of Expert Advisor Visual Wizard allows you to create visual representations of forex trading strategies and signals as you would with pencil and paper. These trading diagrams are analyzed automatically by Molanis’ MQL5 code generator that transforms them into ready to use Expert Advisors. The interactive graphical environment simplifies the design process and eliminates the need to write MQL5 code.
Universal Regression Model for Market Price Prediction
Universal Regression Model for Market Price Prediction

Universal Regression Model for Market Price Prediction

The market price is formed out of a stable balance between demand and supply which, in turn, depend on a variety of economic, political and psychological factors. Differences in nature as well as causes of influence of these factors make it difficult to directly consider all the components. This article sets forth an attempt to predict the market price on the basis of an elaborated regression model.
The Role of Statistical Distributions in Trader's Work
The Role of Statistical Distributions in Trader's Work

The Role of Statistical Distributions in Trader's Work

This article is a logical continuation of my article Statistical Probability Distributions in MQL5 which set forth the classes for working with some theoretical statistical distributions. Now that we have a theoretical base, I suggest that we should directly proceed to real data sets and try to make some informational use of this base.
Custom Graphical Controls. Part 3. Forms
Custom Graphical Controls. Part 3. Forms

Custom Graphical Controls. Part 3. Forms

This is the last of the three articles devoted to graphical controls. It covers the creation of the main graphical interface component - the form - and its use in combination with other controls. In addition to the form classes, CFrame, CButton, CLabel classes have been added to the control library.
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.
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.