Articles with MQL5 programming examples

icon

Access a huge collection of articles with code examples showing how to create indicators and trading robots for the MetaTrader platform in the MQL5 language. Source codes are attached to the articles, so you can open them in MetaEditor and run them to see how the applications work.

These articles will be useful both for those who have just started exploring automated trading and for professional traders with programming experience. They feature not only examples, but also contain new ideas.

Add a new article
latest | best
An Expert Advisor Made to Order. Manual for a Trader
An Expert Advisor Made to Order. Manual for a Trader

An Expert Advisor Made to Order. Manual for a Trader

Not all traders are programmers. And not all of the programmers are really good ones. So, what should be done, if you need to automate your system by do not have time and desire to study MQL4?
Equivolume Charting Revisited
Equivolume Charting Revisited

Equivolume Charting Revisited

The article dwells on the method of constructing charts, at which each bar consists of the equal number of ticks.
MQL4 Language for Newbies. Custom Indicators (Part 2)
MQL4 Language for Newbies. Custom Indicators (Part 2)

MQL4 Language for Newbies. Custom Indicators (Part 2)

This is the fifth article from the series "MQL4 Languages for Newbies". Today we will learn to use graphical objects - a very powerful development tool that allows to widen substantially possibilities of using indicators. Besides, they can be used in scripts and Expert Advisors. We will learn to create objects, change their parameters, check errors. Of course, I cannot describe in details all objects - there are a lot of them. But you will get all necessary knowledge to be able to study them yourself. This article also contains a step-by-step guide-example of creating a complex signal indicator. At that, many parameters will be adjustable which will make it possible to change easily the appearance of the indicator.
Displaying a News Calendar
Displaying a News Calendar

Displaying a News Calendar

This article contains the description of writing a simple and convenient indicator displaying in a working area the main economic events from external Internet resources.
MQL4 Language for Newbies. Custom Indicators (Part 1)
MQL4 Language for Newbies. Custom Indicators (Part 1)

MQL4 Language for Newbies. Custom Indicators (Part 1)

This is the fourth article from the series "MQL4 Languages for Newbies". Today we will learn to write custom indicators. We will get acquainted with the classification of indicator features, will see how these features influence the indicator, will learn about new functions and optimization, and, finally, we will write our own indicators. Moreover, at the end of the article you will find advice on the programming style. If this is the first article "for newbies" that you are reading, perhaps it would be better for you to read the previous ones. Besides, make sure that you have understood properly the previous material, because the given article does not explain the basics.
MT4TerminalSync - System for the Synchronization of MetaTrader 4 Terminals
MT4TerminalSync - System for the Synchronization of MetaTrader 4 Terminals

MT4TerminalSync - System for the Synchronization of MetaTrader 4 Terminals

This article is devoted to the topic "Widening possibilities of MQL4 programs by using functions of operating systems and other means of program development". The article describes an example of a program system that implements the task of the synchronization of several terminal copies based on a single source template.
Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?
Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?

Can the Forex Market Be Forecasted? How to Create One's Own Trading Strategy?

Everyone starting to work in Forex tries to answer these questions. But not everyone finds the answer, even after many years of hard work and search. I personally have answered this question, as well as many other questions of this article. As a result of these answers a way of creating an efficient trading strategy was determined.
Transferring an Indicator Code into an Expert Advisor Code. Conclusion
Transferring an Indicator Code into an Expert Advisor Code. Conclusion

Transferring an Indicator Code into an Expert Advisor Code. Conclusion

This is the final article, devoted to transferring an indicator code into an Expert Advisor code. Here the author transforms on a certain example a code of an Expert Advisor so, that this EA is presented in a single file without calling custom indicators.
Using Skype to Send Messages from an Expert Advisor
Using Skype to Send Messages from an Expert Advisor

Using Skype to Send Messages from an Expert Advisor

The article deals with the ways of how to send internal messages and SMSes from an Expert Advisor to mobile phones using Skype.
Transferring an Indicator Code into an Expert Advisor Code. General Structural Schemes of an Expert Advisor and Indicator Functions
Transferring an Indicator Code into an Expert Advisor Code. General Structural Schemes of an Expert Advisor and Indicator Functions

Transferring an Indicator Code into an Expert Advisor Code. General Structural Schemes of an Expert Advisor and Indicator Functions

This article dwells on the ways of transferring an indicator code into an Expert Advisor Code and on writing Expert Advisors with no calling to custom indicators, and with the whole program code for the calculation of necessary indicator values inside the Expert Advisor. This article gives a general scheme of Expert Advisor changing and the idea of building an indicator function based on a custom indicator. The article is intended for readers, already having experience of programming in MQL4 language.
Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure
Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure

Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure

This article dwells on the ways of transferring an indicator code into an Expert Advisor Code and on writing Expert Advisors with no calling to custom indicators, and with the whole program code for the calculation of necessary indicator values inside the Expert Advisor. This article gives a general scheme of an indicator structure, emulation of indicator buffers in an Expert Advisor and substitution of the function IndicatorCounted(). The article is intended for readers, already having experience of programming in MQL4 language.
MetaTrader 4 Working under Antiviruses and Firewalls
MetaTrader 4 Working under Antiviruses and Firewalls

MetaTrader 4 Working under Antiviruses and Firewalls

The most of traders use special programs to protect their PCs. Unfortunately, these programs don't only protect computers against intrusions, viruses and Trojans, but also consume a significant amount of resources. This relates to network traffic, first of all, which is wholly controlled by various intelligent antiviruses and firewalls. The reason for writing this article was that traders complained of slowed MetaTrader 4 Client Terminal when working with Outpost Firewall. We decided to make our own research using Kaspersky Antivirus 6.0 and Outpost Firewall Pro 4.0.
Indicator Alternative Ichimoku – Setup, Examples of Usage
Indicator Alternative Ichimoku – Setup, Examples of Usage

Indicator Alternative Ichimoku – Setup, Examples of Usage

How to set up Alternative Ichimoku correctly? Read the description of parameters setting up. The article will help you understand the methods of setting up parameters not only of the indicator Ichimoku. Certainly you will also better understand how to set up the standard Ichimoku Kinko Hyo.
Three-Dimensional Graphs - a Professional Tool of Market Analyzing
Three-Dimensional Graphs - a Professional Tool of Market Analyzing

Three-Dimensional Graphs - a Professional Tool of Market Analyzing

In this article we will write a simple library for the construction of 3D graphs and their further viewing in Microsoft Excel. We will use standard MQL4 options to prepare and export data into *.csv file.
Practical Application of Cluster Indicators in FOREX
Practical Application of Cluster Indicators in FOREX

Practical Application of Cluster Indicators in FOREX

Cluster indicators are sets of indicators that divide currency pairs into separate currencies. Indicators allow to trace the relative currency fluctuation, determine the potential of forming new currency trends, receive trade signals and follow medium-term and long-term positions.
Technical Analysis: Make the Impossible Possible!
Technical Analysis: Make the Impossible Possible!

Technical Analysis: Make the Impossible Possible!

The article answers the question: Why can the impossible become possible where much suggests otherwise? Technical analysis reasoning.
Breakpoints in Tester: It's Possible!
Breakpoints in Tester: It's Possible!

Breakpoints in Tester: It's Possible!

The article deals with breakpoint emulation when passed through Tester, debug information being displayed.
Construction of Fractal Lines
Construction of Fractal Lines

Construction of Fractal Lines

The article describes construction of fractal lines of various types using trend lines and fractals.
MQL4 Language for Newbies. Technical Indicators and Built-In Functions
MQL4 Language for Newbies. Technical Indicators and Built-In Functions

MQL4 Language for Newbies. Technical Indicators and Built-In Functions

This is the third article from the series "MQL4 Language for Newbies". Now we will learn to use built-in functions and functions for working with technical indicators. The latter ones will be essential in the future development of your own Expert Advisors and indicators. Besides we will see on a simple example, how we can trace trading signals for entering the market, for you to understand, how to use indicators correctly. And at the end of the article you will learn something new and interesting about the language itself.
Practical Use of the Virtual Private Server (VPS) for Autotrading
Practical Use of the Virtual Private Server (VPS) for Autotrading

Practical Use of the Virtual Private Server (VPS) for Autotrading

Autotrading using VPS. This article is intended exceptionally for autotraders and autotrading supporters.
ZUP - Universal ZigZag with Pesavento Patterns. Part 2
ZUP - Universal ZigZag with Pesavento Patterns. Part 2

ZUP - Universal ZigZag with Pesavento Patterns. Part 2

ZUP - Universal ZigZag with Pesavento Patterns. Part 2 - Description of Embedded Tools
Strings: Table of ASCII Symbols and Its Use
Strings: Table of ASCII Symbols and Its Use

Strings: Table of ASCII Symbols and Its Use

In this article we will analyze the table of ASCII symbols and the ways it can be used. We will also deal with some new functions, the principle of operation of which is based on the peculiarities of the ASCII table, and then we will create a new library, which will include these functions. They are quite popular in other programming languages, but they are not included into the list of built-in functions. Besides, we will examine in details the basics of working with strings. So, I think you will certainly learn something new about this useful type of data.
Interaction between MetaTrader 4 and Matlab via CSV Files
Interaction between MetaTrader 4 and Matlab via CSV Files

Interaction between MetaTrader 4 and Matlab via CSV Files

Step-by-step instructions of how to organize data arrays exchange between MetaTrader 4 and Matlab via CSV files.
Sending Trading Signals in a Universal Expert Advisor
Sending Trading Signals in a Universal Expert Advisor

Sending Trading Signals in a Universal Expert Advisor

The article describes different ways of sending trading signals from a signal program unit of a universal Expert Advisor into the positions and orders controlling unit. It dwells on serial and parallel interfaces.
Theoretical Basis of Building Cluster Indicators for FOREX
Theoretical Basis of Building Cluster Indicators for FOREX

Theoretical Basis of Building Cluster Indicators for FOREX

Cluster indicators are sets of indicators that divide currency pairs into separate currencies. Indicators allow to trace the relative currency fluctuation, determine the potential of formating new currency trends, receive trade signals and follow medium-term and long-term positons.
Tricolor Indicators and Some Opportunities for Maximal Simplification of Writing Indicators
Tricolor Indicators and Some Opportunities for Maximal Simplification of Writing Indicators

Tricolor Indicators and Some Opportunities for Maximal Simplification of Writing Indicators

In this article the author dwells on some means of increasing indicators' informational value for visual trading. The author analyzes the realization of tricolor indicators, indicators, for building which data from other timeframes is used, and continues to dwell on the library of indicators, described in the article "Effective Averaging Algorithms with Minimal Lag: Use in Indicators"
Forex Trading ABC
Forex Trading ABC

Forex Trading ABC

Working on financial markets represents, first of all, trade operations. We all, starting from the very childhood, have an intuitive idea of what is to buy and to sell. But Forex trading is still something special. This article deals with the ideas necessary to explain some terms. We will also consider the MQL 4 functions that correspond with those terms.
Sending Trade Signal Via RSS Feed
Sending Trade Signal Via RSS Feed

Sending Trade Signal Via RSS Feed

This is my idea how to send your trade signal as RSS FEEDS , a famous way to communicate with your community's members right now.
The Basic of Coding A Hedge Expert Advisor
The Basic of Coding A Hedge Expert Advisor

The Basic of Coding A Hedge Expert Advisor

An example of hedge Expert Advisor is just presented in this article. The author will choose its very own favorite hedge pair that is EURJPY & GBPJPY. It always moves the same way, easier to set the hedging order type.
ZUP - Universal ZigZag with Pesavento Patterns. Part 1
ZUP - Universal ZigZag with Pesavento Patterns. Part 1

ZUP - Universal ZigZag with Pesavento Patterns. Part 1

The article gives a short description of ideas underlying indicator ZUP - Universal ZigZag with Pesavento Patterns. The article also describes indicators of ZigZag embedded in ZUP.
MQL4 Language for Newbies. Difficult Questions in Simple Phrases.
MQL4 Language for Newbies. Difficult Questions in Simple Phrases.

MQL4 Language for Newbies. Difficult Questions in Simple Phrases.

This is the second article from the series "MQL4 Language for Newbies". Now we will examine more complex and advanced constructions of the language, learn new options and see, how they can be applied in everyday practice. You will get acquainted with a new cycle type 'while', new condition type 'switch', operators 'break' and 'continue'. Besides you will learn to write your own functions and work with multidimensional arrays. And for a dessert I have prepared an explanation about a preprocessor.
Running MetaTrader 4 Client Terminal on Linux-Desktop
Running MetaTrader 4 Client Terminal on Linux-Desktop

Running MetaTrader 4 Client Terminal on Linux-Desktop

Description of a step-by-step Linux-desktop setup using a non-emulator wine for running MetaTrader 4 Client Terminal on it.
MQL4 Language for Newbies. Introduction
MQL4 Language for Newbies. Introduction

MQL4 Language for Newbies. Introduction

This sequence of articles is intended for traders, who know nothing about programming, but have a desire to learn MQL4 language as quick as possible with minimal time and effort inputs. If you are afraid of such phrases as "object orientation" or "three dimensional arrays", this article is what you need. The lessons are designed for the maximally quick result. Moreover, the information is delivered in a comprehensible manner. We shall not go too deep into the theory, but you will gain the practical benefit already from the first lesson.
Alternative Log File with the Use of HTML and CSS
Alternative Log File with the Use of HTML and CSS

Alternative Log File with the Use of HTML and CSS

In this article we will describe the process of writing a simple but a very powerful library for making the html files, will learn to adjust their displaying and will see how they can be easily implemented and used in your expert or the script.
Simultaneous Displaying of the Signals of Several Indicators from the Four Timeframes
Simultaneous Displaying of the Signals of Several Indicators from the Four Timeframes

Simultaneous Displaying of the Signals of Several Indicators from the Four Timeframes

While manual trading you have to keep an eye on the values of several indicators. It is a little bit different from mechanical trading. If you have two or three indicators and you have chosen a one timeframe for trading, it is not a complicated task. But what will you do if you have five or six indicators and your trading strategy requires considering the signals on the several timeframes?
Displaying of Support/Resistance Levels
Displaying of Support/Resistance Levels

Displaying of Support/Resistance Levels

The article deals with detecting and indicating Support/Resistance Levels in the MetaTrader 4 program. The convenient and universal indicator is based on a simple algorithm. The article also tackles such a useful topic as creation of a simple indicator that can display results from different timeframes in one workspace.
A Method of Drawing the Support/Resistance Levels
A Method of Drawing the Support/Resistance Levels

A Method of Drawing the Support/Resistance Levels

This article describes the process of creating a simple script for detecting the support/resistance levels. It is written for beginners, so you can find the detailed explanation of every stage of the process. However, though the script is very simple, the article will be also useful for advanced traders and the users of the MetaTrader 4 platform. It contains the examples of the data export into the tabular format, the import of the table to Microsoft Excel and plotting the charts for the further detailed analysis.
Pivot Points Helping to Define Market Trends
Pivot Points Helping to Define Market Trends

Pivot Points Helping to Define Market Trends

Pivot point is a line in the price chart that shows the further trend of a currency pair. If the price is above this line, it tends to grow. If the price is below this line, accordingly, it tends to fall.
Events in МetaТrader 4
Events in МetaТrader 4

Events in МetaТrader 4

The article deals with programmed tracking of events in the МetaТrader 4 Client Terminal, such as opening/closing/modifying orders, and is targeted at a user who has basic skills in working with the terminal and in programming in MQL 4.
Synchronization of Expert Advisors, Scripts and Indicators
Synchronization of Expert Advisors, Scripts and Indicators

Synchronization of Expert Advisors, Scripts and Indicators

The article considers the necessity and general principles of developing a bundled program that would contain both an Expert Advisor, a script and an indicator.