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
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.
Testing and Optimization of Expert Advisors
Testing and Optimization of Expert Advisors

Testing and Optimization of Expert Advisors

The article provides a detailed description of the process of testing and optimizing Expert Advisors in the MetaTrader 4 Strategy Tester. The importance of such information and the need for this publication cannot be underestimated. A lot of users who only get started with the MetaTrader 4 trading platform have a very vague idea of what and how needs to be done when working with Expert Advisors. The proposed article gives simple and clear answers to all of these questions and provides a slightly more professional approach to handling these issues using a specific example.
Lite_EXPERT2.mqh: Expert Advisor Implementation Examples
Lite_EXPERT2.mqh: Expert Advisor Implementation Examples

Lite_EXPERT2.mqh: Expert Advisor Implementation Examples

In this article, the author continues to familiarize the readers with the Lite_EXPERT2.mqh functions using real Expert Advisor implementation examples. The article deals with the idea of using floating pending orders and pending orders that vary dynamically from deal to deal which are determined based on Average True Range (ATR) indicator values.
Advanced Analysis of a Trading Account
Advanced Analysis of a Trading Account

Advanced Analysis of a Trading Account

The article deals with the automatic system for analyzing any trading account in MetaTrader 4 terminal. Technical aspects of a generated report and interpretation of the obtained results are considered. Conclusions on improving trading factors are drawn after the detailed review of the report. MQLab™ Graphic Report script is used for analysis.
Visual Optimization of Indicator and Signal Profitability
Visual Optimization of Indicator and Signal Profitability

Visual Optimization of Indicator and Signal Profitability

This article is a continuation and development of my previous article "Visual Testing of Profitability of Indicators and Alerts". Having added some interactivity to the parameter changing process and having reworked the study objectives, I have managed to get a new tool that does not only show the prospective trade results based on the signals used but also allows you to immediately get a layout of deals, balance chart and the end result of trading by moving virtual sliders that act as controls for signal parameter values in the main chart.
Raise Your Linear Trading Systems to the Power
Raise Your Linear Trading Systems to the Power

Raise Your Linear Trading Systems to the Power

Today's article shows intermediate MQL5 programmers how they can get more profit from their linear trading systems (Fixed Lot) by easily implementing the so-called technique of exponentiation. This is because the resulting equity curve growth is then geometric, or exponential, taking the form of a parabola. Specifically, we will implement a practical MQL5 variant of the Fixed Fractional position sizing developed by Ralph Vince.
MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar
MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar

MQL5 Cookbook: Indicator Subwindow Controls - Scrollbar

Let's continue exploring various controls and this time turn our attention to scrollbar. Just like in the previous article entitled "MQL5 Cookbook: Indicator Subwindow Controls - Buttons", all operations will be performed in the indicator subwindow. Take a moment to read the above mentioned article as it provides a detailed description of working with events in the OnChartEvent() function, while this point will only be casually touched upon in this article. For illustrative purposes, this time around we will create a vertical scrollbar for a large list of all financial instrument properties that can be obtained using MQL5 resources.
MQL5 Cookbook: Indicator Subwindow Controls - Buttons
MQL5 Cookbook: Indicator Subwindow Controls - Buttons

MQL5 Cookbook: Indicator Subwindow Controls - Buttons

In this article, we will consider an example of developing a user interface with button controls. To convey the idea of interactivity to the user, buttons will change their colors when the cursor hovers over them. With the cursor being over a button, the button color will be slightly darkened, getting significantly darker when the button is clicked. Furthermore, we will add tooltips to each button, thus creating an intuitive interface.
MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window
MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window

MQL5 Cookbook: Monitoring Multiple Time Frames in a Single Window

There are 21 time frames available in MetaTrader 5 for analysis. You can take advantage of special chart objects that you can place on the existing chart and set the symbol, time frame and some other properties right there. This article will provide detailed information on such chart graphical objects: we will create an indicator with controls (buttons) that will allow us to set multiple chart objects in a subwindow at the same time. Furthermore, chart objects will accurately fit in the subwindow and will be automatically adjusted when the main chart or terminal window is resized.
MQL5 Cookbook: Sound Notifications for MetaTrader 5 Trade Events
MQL5 Cookbook: Sound Notifications for MetaTrader 5 Trade Events

MQL5 Cookbook: Sound Notifications for MetaTrader 5 Trade Events

In this article, we will consider such issues as including sound files in the file of the Expert Advisor, and thus adding sound notifications to trade events. The fact that the files will be included means that the sound files will be located inside the Expert Advisor. So when giving the compiled version of the Expert Advisor (*.ex5) to another user, you will not have to also provide the sound files and explain where they need to be saved.
Technical Indicators and Digital Filters
Technical Indicators and Digital Filters

Technical Indicators and Digital Filters

In this article, technical indicators are treated as digital filters. Operation principles and basic characteristics of digital filters are explained. Also, some practical ways of receiving the filter kernel in MetaTrader 5 terminal and integration with a ready-made spectrum analyzer proposed in the article "Building a Spectrum Analyzer" are considered. Pulse and spectrum characteristics of the typical digital filters are used as examples.
Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!
Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!

Marvel Your MQL5 Customers with a Usable Cocktail of Technologies!

MQL5 provides programmers with a very complete set of functions and object-oriented API thanks to which they can do everything they want within the MetaTrader environment. However, Web Technology is an extremely versatile tool nowadays that may come to the rescue in some situations when you need to do something very specific, want to marvel your customers with something different or simply you do not have enough time to master a specific part of MT5 Standard Library. Today's exercise walks you through a practical example about how you can manage your development time at the same time as you also create an amazing tech cocktail.
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria
MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria

MQL5 Cookbook: Saving Optimization Results of an Expert Advisor Based on Specified Criteria

We continue the series of articles on MQL5 programming. This time we will see how to get results of each optimization pass right during the Expert Advisor parameter optimization. The implementation will be done so as to ensure that if the conditions specified in the external parameters are met, the corresponding pass values will be written to a file. In addition to test values, we will also save the parameters that brought about such results.
Lite_EXPERT2.mqh: Functional Kit for Developers of Expert Advisors
Lite_EXPERT2.mqh: Functional Kit for Developers of Expert Advisors

Lite_EXPERT2.mqh: Functional Kit for Developers of Expert Advisors

This article continues the series of articles "Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization". It familiarizes the readers with a more universal function library of the Lite_EXPERT2.mqh file.
MetaTrader AppStore Results for Q3 2013
MetaTrader AppStore Results for Q3 2013

MetaTrader AppStore Results for Q3 2013

Another quarter of the year has passed and we have decided to sum up its results for MetaTrader AppStore - the largest store of trading robots and technical indicators for MetaTrader platforms. More than 500 developers have placed over 1 200 products in the Market by the end of the reported quarter.
MQL5 Wizard: How to Teach an EA to Open Pending Orders at Any Price
MQL5 Wizard: How to Teach an EA to Open Pending Orders at Any Price

MQL5 Wizard: How to Teach an EA to Open Pending Orders at Any Price

The article describes a method of modifying the code of a trading signal module for the implementation of the functionality allowing you to set pending orders at any distance from the current price: it may be the Close or Open price of the previous bar or the value of the moving average. There are plenty of options. Important is that you can set any opening price for a pending order. This article will be useful to traders who trade with pending orders.
MQL5 Cookbook: Reducing the Effect of Overfitting and Handling the Lack of Quotes
MQL5 Cookbook: Reducing the Effect of Overfitting and Handling the Lack of Quotes

MQL5 Cookbook: Reducing the Effect of Overfitting and Handling the Lack of Quotes

Whatever trading strategy you use, there will always be a question of what parameters to choose to ensure future profits. This article gives an example of an Expert Advisor with a possibility to optimize multiple symbol parameters at the same time. This method is intended to reduce the effect of overfitting parameters and handle situations where data from a single symbol are not enough for the study.
EA Status SMS Notifications
EA Status SMS Notifications

EA Status SMS Notifications

Developing a system of SMS notifications that informs you of the status of your EA so that you are always aware of any critical situation, wherever you may be.
How to Make Money from MetaTrader AppStore and Trading Signals Services If You Are Not a Seller or a Provider
How to Make Money from MetaTrader AppStore and Trading Signals Services If You Are Not a Seller or a Provider

How to Make Money from MetaTrader AppStore and Trading Signals Services If You Are Not a Seller or a Provider

It is possible to start making money on MQL5.com right now without having to be a seller of Market applications or a profitable signals provider. Select the products you like and post links to them on various web resources. Attract potential customers and the profit is yours!
Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator
Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator

Creating Neural Network EAs Using MQL5 Wizard and Hlaiman EA Generator

The article describes a method of automated creation of neural network EAs using MQL5 Wizard and Hlaiman EA Generator. It shows you how you can easily start working with neural networks, without having to learn the entire body of theoretical information and writing your own code.
Extending MQL5 Standard Library and Reusing Code
Extending MQL5 Standard Library and Reusing Code

Extending MQL5 Standard Library and Reusing Code

MQL5 Standard Library makes your life as a developer easier. Nevertheless, it does not implement all the needs of all developers in the world, so if you feel that you need some more custom stuff you can take a step further and extend. This article walks you through integrating MetaQuotes' Zig-Zag technical indicator into the Standard Library. We get inspired by MetaQuotes' design philosophy to achieve our goal.
Expert Advisor for Trading in the Channel
Expert Advisor for Trading in the Channel

Expert Advisor for Trading in the Channel

The Expert Advisor plots the channel lines. The upper and lower channel lines act as support and resistance levels. The Expert Advisor marks datum points, provides sound notification every time the price reaches or crosses the channel lines and draws the relevant marks. Upon fractal formation, the corresponding arrows appear on the last bars. Line breakouts may suggest the possibility of a growing trend. The Expert Advisor is extensively commented throughout.
Trading Signal Generator Based on a Custom Indicator
Trading Signal Generator Based on a Custom Indicator

Trading Signal Generator Based on a Custom Indicator

How to create a trading signal generator based on a custom indicator? How to create a custom indicator? How to get access to custom indicator data? Why do we need the IS_PATTERN_USAGE(0) structure and model 0?
Simple Methods of Forecasting Directions of the Japanese Candlesticks
Simple Methods of Forecasting Directions of the Japanese Candlesticks

Simple Methods of Forecasting Directions of the Japanese Candlesticks

Knowing the direction of the price movement is sufficient for getting positive results from trading operations. Some information on the possible direction of the price can be obtained from the Japanese candlesticks. This article deals with a few simple approaches to forecasting the direction of the Japanese candlesticks.
Building an Automatic News Trader
Building an Automatic News Trader

Building an Automatic News Trader

This is the continuation of Another MQL5 OOP class article which showed you how to build a simple OO EA from scratch and gave you some tips on object-oriented programming. Today I am showing you the technical basics needed to develop an EA able to trade the news. My goal is to keep on giving you ideas about OOP and also cover a new topic in this series of articles, working with the file system.
How Reliable is Night Trading?
How Reliable is Night Trading?

How Reliable is Night Trading?

The article covers the peculiarities of night flat trading on cross currency pairs. It explains where you can expect profits and why great losses are not unlikely. The article also features an example of the Expert Advisor developed for night trading and talks about the practical application of this strategy.
MQL5 Cookbook: Writing the History of Deals to a File and Creating Balance Charts for Each Symbol in Excel
MQL5 Cookbook: Writing the History of Deals to a File and Creating Balance Charts for Each Symbol in Excel

MQL5 Cookbook: Writing the History of Deals to a File and Creating Balance Charts for Each Symbol in Excel

When communicating in various forums, I often used examples of my test results displayed as screenshots of Microsoft Excel charts. I have many times been asked to explain how such charts can be created. Finally, I now have some time to explain it all in this article.
Money Management Revisited
Money Management Revisited

Money Management Revisited

The article deals with some issues arising when traders apply various money management systems to Forex trading. Experimental data obtained from performing trading deals using different money management (MM) methods is also described.
Another MQL5 OOP Class
Another MQL5 OOP Class

Another MQL5 OOP Class

This article shows you how to build an Object-Oriented Expert Advisor from scratch, from conceiving a theoretical trading idea to programming a MQL5 EA that makes that idea real in the empirical world. Learning by doing is IMHO a solid approach to succeed, so I am showing a practical example in order for you to see how you can order your ideas to finally code your Forex robots. My goal is also to invite you to adhere the OO principles.
Alert and Comment for External Indicators (Part Two)
Alert and Comment for External Indicators (Part Two)

Alert and Comment for External Indicators (Part Two)

Since I published the article "Alert and Comment for External Indicators", I have been receiving requests and questions regarding the possibility of developing an external informer operating based on indicator lines. Having analyzed the questions, I have decided to continue with the subject. Getting data stored in indicator buffers turned out to be another area of interest to users.
Alert and Comment for External Indicators. Multi-Currency Analysis Through External Scanning
Alert and Comment for External Indicators. Multi-Currency Analysis Through External Scanning

Alert and Comment for External Indicators. Multi-Currency Analysis Through External Scanning

Alert for multi-currency and multiple time frame analysis of external indicators. The article deals with a method of getting event information in respect of events in external indicators, without having to attach indicators to a chart or open charts themselves. We will call it external scanning.
MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters
MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters

MQL5 Cookbook: Developing a Multi-Currency Expert Advisor with Unlimited Number of Parameters

In this article, we will create a pattern that uses a single set of parameters for optimization of a trading system, while allowing for unlimited number of parameters. The list of symbols will be created in a standard text file (*.txt). Input parameters for each symbol will also be stored in files. This way we will be able to circumvent the restriction of the terminal on the number of input parameters of an Expert Advisor.
Graphical Control of External Parameters of Indicators
Graphical Control of External Parameters of Indicators

Graphical Control of External Parameters of Indicators

External variables of indicators are controlled using a special window where parameters can be changed and the indicator is then run again. The obvious inconvenience of these manipulations has given rise to the need for displaying the required parameters on the screen and controlling the indicator graphically.
Social Trading with the MetaTrader 4 and MetaTrader 5 Trading Platforms
Social Trading with the MetaTrader 4 and MetaTrader 5 Trading Platforms

Social Trading with the MetaTrader 4 and MetaTrader 5 Trading Platforms

What is social trading? It is a mutually beneficial cooperation of traders and investors whereby successful traders allow monitoring of their trading and potential investors take the opportunity to monitor their performance and copy trades of those who look more promising.
MQL5 Market Results for Q2 2013
MQL5 Market Results for Q2 2013

MQL5 Market Results for Q2 2013

Successfully operating for 1.5 years, MQL5 Market has become the largest traders' store of trading strategies and technical indicators. It offers around 800 trading applications provided by 350 developers from around the world. Over 100.000 trading programs have already been purchased and downloaded by traders to their MetaTrader 5 terminals.
Testing Expert Advisors on Non-Standard Time Frames
Testing Expert Advisors on Non-Standard Time Frames

Testing Expert Advisors on Non-Standard Time Frames

It's not just simple; it's super simple. Testing Expert Advisors on non-standard time frames is possible! All we need to do is to replace standard time frame data with non-standard time frame data. Furthermore, we can even test Expert Advisors that use data from several non-standard time frames.
How to Install and Use OpenCL for Calculations
How to Install and Use OpenCL for Calculations

How to Install and Use OpenCL for Calculations

It has been over a year since MQL5 started providing native support for OpenCL. However not many users have seen the true value of using parallel computing in their Expert Advisors, indicators or scripts. This article serves to help you install and set up OpenCL on your computer so that you can try to use this technology in the MetaTrader 5 trading terminal.
Reading RSS News Feeds by Means of MQL4
Reading RSS News Feeds by Means of MQL4

Reading RSS News Feeds by Means of MQL4

This article deals with an example of reading RSS markup by means of MQL4 using the functions for HTML tags analysis. We will try to make a work piece which can then be turned into a news indicator or just an RSS reader on MQL4 language.
LibMatrix: Library of Matrix Algebra (Part One)
LibMatrix: Library of Matrix Algebra (Part One)

LibMatrix: Library of Matrix Algebra (Part One)

The author familiarizes the readers with a simple library of matrix algebra and provides descriptions and peculiarities of the main functions.
Mechanical Trading System "Chuvashov's Triangle"
Mechanical Trading System "Chuvashov's Triangle"

Mechanical Trading System "Chuvashov's Triangle"

Let me offer you an overview and the program code of the mechanical trading system based on ideas of Stanislav Chuvashov. Triangle's construction is based on the intersection of two trend lines built by the upper and lower fractals.