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
The Golden Rule of Traders
The Golden Rule of Traders

The Golden Rule of Traders

In order to make profits based on high expectations, we must understand three basic principles of good trading: 1) know your risk when entering the market; 2) cut your losses early and allow your profit to run; 3) know the expectation of your system – test and adjust it regularly. This article provides a program code trailing open positions and actualizing the second golden principle, as it allows profit to run for the highest possible level.
Visualize a Strategy in the MetaTrader 5 Tester
Visualize a Strategy in the MetaTrader 5 Tester

Visualize a Strategy in the MetaTrader 5 Tester

We all know the saying "Better to see once than hear a hundred times". You can read various books about Paris or Venice, but based on the mental images you wouldn't have the same feelings as on the evening walk in these fabulous cities. The advantage of visualization can easily be projected on any aspect of our lives, including work in the market, for example, the analysis of price on charts using indicators, and of course, the visualization of strategy testing. This article contains descriptions of all the visualization features of the MetaTrader 5 Strategy Tester.
preview
Get 200 usd for your algorithmic trading article!

Get 200 usd for your algorithmic trading article!

Write an article and contribute to the development of algorithmic trading. Share your experience in trading and programming, and we will pay you $200. Additionally, publishing an article on the popular MQL5.com website offers an excellent opportunity to promote your personal brand in a professional community. Thousands of traders will read your work. You can discuss your ideas with like-minded people, gain new experience, and monetize your knowledge.
Kernel Density Estimation of the Unknown Probability Density Function
Kernel Density Estimation of the Unknown Probability Density Function

Kernel Density Estimation of the Unknown Probability Density Function

The article deals with the creation of a program allowing to estimate the kernel density of the unknown probability density function. Kernel Density Estimation method has been chosen for executing the task. The article contains source codes of the method software implementation, examples of its use and illustrations.
OpenCL: The Bridge to Parallel Worlds
OpenCL: The Bridge to Parallel Worlds

OpenCL: The Bridge to Parallel Worlds

In late January 2012, the software development company that stands behind the development of MetaTrader 5 announced native support for OpenCL in MQL5. Using an illustrative example, the article sets forth the programming basics in OpenCL in the MQL5 environment and provides a few examples of the naive optimization of the program for the increase of operating speed.
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!
A Few Tips for First-Time Customers
A Few Tips for First-Time Customers

A Few Tips for First-Time Customers

A proverbial wisdom often attributed to various famous people says: "He who makes no mistakes never makes anything." Unless you consider idleness itself a mistake, this statement is hard to argue with. But you can always analyze the past mistakes (your own and of others) to minimize the number of your future mistakes. We are going to attempt to review possible situations arising when executing jobs in the same-name service.
Trader's Kit: Drag Trade Library
Trader's Kit: Drag Trade Library

Trader's Kit: Drag Trade Library

The article describes Drag Trade Library that provides functionality for visual trading. The library can easily be integrated into virtually any Expert Advisor. Your Expert Advisor can be transformed from an automat into an automated trading and information system almost effortless on your side by just adding a few lines of code.
Synthetic Bars - A New Dimension to Displaying Graphical Information on Prices
Synthetic Bars - A New Dimension to Displaying Graphical Information on Prices

Synthetic Bars - A New Dimension to Displaying Graphical Information on Prices

The main drawback of traditional methods for displaying price information using bars and Japanese candlesticks is that they are bound to the time period. It was perhaps optimal at the time when these methods were created but today when the market movements are sometimes too rapid, prices displayed in a chart in this way do not contribute to a prompt response to the new movement. The proposed price chart display method does not have this drawback and provides a quite familiar layout.
The Simple Example of Creating an Indicator Using Fuzzy Logic
The Simple Example of Creating an Indicator Using Fuzzy Logic

The Simple Example of Creating an Indicator Using Fuzzy Logic

The article is devoted to the practical application of the fuzzy logic concept for financial markets analysis. We propose the example of the indicator generating signals based on two fuzzy rules based on Envelopes indicator. The developed indicator uses several indicator buffers: 7 buffers for calculations, 5 buffers for the charts display and 2 color buffers.
AutoElliottWaveMaker - MetaTrader 5 Tool for Semi-Automatic Analysis of Elliott Waves
AutoElliottWaveMaker - MetaTrader 5 Tool for Semi-Automatic Analysis of Elliott Waves

AutoElliottWaveMaker - MetaTrader 5 Tool for Semi-Automatic Analysis of Elliott Waves

The article provides a review of AutoElliottWaveMaker - the first development for Elliott Wave analysis in MetaTrader 5 that represents a combination of manual and automatic wave labeling. The wave analysis tool is written exclusively in MQL5 and does not include external dll libraries. This is another proof that sophisticated and interesting programs can (and should) be developed in MQL5.
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.
Mechanical Trading System "Chuvashov's Fork"
Mechanical Trading System "Chuvashov's Fork"

Mechanical Trading System "Chuvashov's Fork"

This article draws your attention to the brief review of the method and program code of the mechanical trading system based on the technique proposed by Stanislav Chuvashov. The market analysis considered in the article has something in common with Thomas DeMark's approach to drawing trend lines for the last closest time interval, fractals being the reference points in the construction of trend lines.
Econometrics EURUSD One-Step-Ahead Forecast
Econometrics EURUSD One-Step-Ahead Forecast

Econometrics EURUSD One-Step-Ahead Forecast

The article focuses on one-step-ahead forecasting for EURUSD using EViews software and a further evaluation of forecasting results using the programs in EViews. The forecast involves regression models and is evaluated by means of an Expert Advisor developed for MetaTrader 4.
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.
Fractal Analysis of Joint Currency Movements
Fractal Analysis of Joint Currency Movements

Fractal Analysis of Joint Currency Movements

How independent are currency quotes? Are their movements coordinated or does the movement of one currency suggest nothing of the movement of another? The article describes an effort to tackle this issue using nonlinear dynamics and fractal geometry methods.
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!
On Methods of Technical Analysis and Market Forecasting
On Methods of Technical Analysis and Market Forecasting

On Methods of Technical Analysis and Market Forecasting

The article demonstrates the capabilities and potential of a well-known mathematical method coupled with visual thinking and an "out of the box" market outlook. On the one hand, it serves to attract the attention of a wide audience as it can get the creative minds to reconsider the trading paradigm as such. And on the other, it can give rise to alternative developments and program code implementations regarding a wide range of tools for analysis and forecasting.
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.