MQL4 Programming Articles

icon

Here you can find articles on MQL4 - programming language of trading strategies. Most of them are written by traders and active members of MQL5.community. For more convenience, all articles are grouped into several categories - Experts, Indicators, Trading Systems, etc.

Watch out for new articles and discuss them on the Forum!

Add a new article
latest | best
How To Implement Your Own Optimization Criteria
How To Implement Your Own Optimization Criteria

How To Implement Your Own Optimization Criteria

In this article an example of optimization by profit/drawdown criterion with results returned into a file is developed for a standard Expert Advisor - Moving Average.
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.
Mathematics in Trading: How to Estimate Trade Results
Mathematics in Trading: How to Estimate Trade Results

Mathematics in Trading: How to Estimate Trade Results

We all are aware of that "No profit obtained in the past will guarantee any success in future". However, it is still very actual to be able to estimate trading systems. This article deals with some simple and convenient methods that will help to estimate trade results.
What is Martingale and Is It Reasonable to Use It?
What is Martingale and Is It Reasonable to Use It?

What is Martingale and Is It Reasonable to Use It?

This article contains a detailed description of the Martingale system, as well as precise mathematical calculations, necessary for answering the question: "Is it reasonable to use Martingale?".
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.
Creation of an Automated Trading System
Creation of an Automated Trading System

Creation of an Automated Trading System

You must admit that it sounds alluringly - you become a fortunate possessor of a program that can develop for you a profitable automated trading system (ATC) within a few minutes. All you need is to enter desirable inputs and press Enter. And - here you are, take your ATC tested and having positive expected payoff. Where thousands of people spend thousands of hours on developing that very unique ATC, which will "wine and dine", these statements soundб to put it mildly, very hollow. On the one hand, this really looks a little larger than life... However, to my mind, this problem can be solved.
How to Cut an EA Code for an Easier Life and Fewer Errors
How to Cut an EA Code for an Easier Life and Fewer Errors

How to Cut an EA Code for an Easier Life and Fewer Errors

A simple concept described in the article allows those developing automated trading systems in MQL4 to simplify existing trading systems, as well as reduce time needed for development of new systems due to shorter codes.
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.
Price Forecasting Using Neural Networks
Price Forecasting Using Neural Networks

Price Forecasting Using Neural Networks

Many traders speak about neural networks, but what they are and what they really can is known to few people. This article sheds some light on the world of artificial intelligence. It describes, how to prepare correctly the data for the network. Here you will also find an example of forecasting using means of the program Matlab.
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.
Testing Visualization: Account State Charts
Testing Visualization: Account State Charts

Testing Visualization: Account State Charts

Enjoy the process of testing with charts, displaying the balance - now all the necessary information is always in view!
Non-standard Automated Trading
Non-standard Automated Trading

Non-standard Automated Trading

Successful and comfortable trading using MT4 platform without detailed market analysis - is it possible? Can such trading be implemented in practice? I suppose, yes. Especially in terms of the automated trading!
Tester in the Terminal MetaTrader 4: It Should Be Known
Tester in the Terminal MetaTrader 4: It Should Be Known

Tester in the Terminal MetaTrader 4: It Should Be Known

The elaborate interface of the terminal MetaTrader 4 is a forefront, but beside this the terminal includes a deep-laid tester of strategies. And while the worth of MetaTrader 4 as a trading terminal is obvious, the quality of the tester's strategy testing can be assessed only in practice. This article shows the advantages and conveniences of testing in MetaTrader 4.
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.
How to Develop a Reliable and Safe Trade Robot in MQL 4
How to Develop a Reliable and Safe Trade Robot in MQL 4

How to Develop a Reliable and Safe Trade Robot in MQL 4

The article deals with the most common errors that occur in developing and using of an Expert Advisor. An exemplary safe automated trading system is described, as well.
Modelling Requotes in Tester and Expert Advisor Stability Analysis
Modelling Requotes in Tester and Expert Advisor Stability Analysis

Modelling Requotes in Tester and Expert Advisor Stability Analysis

Requote is a scourge for many Expert Advisors, especially for those that have rather sensitive conditions of entering/exiting a trade. In the article, a way to check up the EA for the requotes stability is offered.
Ten "Errors" of a Newcomer in Trading?
Ten "Errors" of a Newcomer in Trading?

Ten "Errors" of a Newcomer in Trading?

The article substantiates approach to building a trading system as a sequence of opening and closing the interrelated orders regarding the existing conditions - prices and the current values of each order's profit/loss, not only and not so much the conventional "alerts". We are giving an exemplary realization of such an elementary trading system.
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?
Sound Alerts in Indicators
Sound Alerts in Indicators

Sound Alerts in Indicators

How to create "voice" indicators for daily usage.
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.
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer
Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer

Genetic Algorithms vs. Simple Search in the MetaTrader 4 Optimizer

The article compares the time and results of Expert Advisors' optimization using genetic algorithms and those obtained by simple search.
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.
Expert System 'Commentator'. Practical Use of Embedded Indicators in an MQL4 Program
Expert System 'Commentator'. Practical Use of Embedded Indicators in an MQL4 Program

Expert System 'Commentator'. Practical Use of Embedded Indicators in an MQL4 Program

The article describes the use of technical indicators in programming on MQL4.
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.