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
Problems of Technical Analysis Revisited
Problems of Technical Analysis Revisited

Problems of Technical Analysis Revisited

At present, technical analysis along with the fundamental one is the most important method to analyze stock market. Being one of the predicting methods of stock market pricing dynamics, the technical analysis has a large amount of disadvantages that cast some doubt on its practical applicability.
Applying fuzzy logic in trading by means of MQL4
Applying fuzzy logic in trading by means of MQL4

Applying fuzzy logic in trading by means of MQL4

The article deals with examples of applying fuzzy set theory in trading by means of MQL4. The use of FuzzyNet library for MQL4 in the development of an indicator and an Expert Advisor is described as well.
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.
Orders Management - It's Simple
Orders Management - It's Simple

Orders Management - It's Simple

The article deals with various ways of how to control open positions and pending orders. It is devoted to simplifying of writing Expert Advisors.
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.
Strategy Tester: Modes of Modeling during Testing
Strategy Tester: Modes of Modeling during Testing

Strategy Tester: Modes of Modeling during Testing

Many programs of technical analysis allow to test trading strategies on history data. In the most cases, the testing is conducted on already completed data without any attempts to model the trends within a price bar. It was made quickly, but not precisely
Data Structure in MetaTrader 4 Build 600 and Higher
Data Structure in MetaTrader 4 Build 600 and Higher

Data Structure in MetaTrader 4 Build 600 and Higher

MetaTarder 4 build 600 features the new structure and location of the client terminal files. Now, MQL4 applications are placed in separate directories according to the program type (Expert Advisors, indicators or scripts). In most cases, the terminal data is now stored in a special data folder separated from the terminal installation location. In this article, we will describe in details how data is transferred, as well as the reasons for introducing the new storage system.
Features of Experts Advisors
Features of Experts Advisors

Features of Experts Advisors

Creation of expert advisors in the MetaTrader trading system has a number of features.
Secrets of MetaTrader 4 Client Terminal
Secrets of MetaTrader 4 Client Terminal

Secrets of MetaTrader 4 Client Terminal

21 way to ease the life: Latent features in MetaTrader 4 Client Terminal. Full screen; hot keys; Fast Navigation bar; minimizing windows; favorites; traffic reduction; disabling of news; symbol sets; Market Watch; templates for testing and independent charts; profiles; crosshair; electronic ruler; barwise chart paging; account history in the chart; types of pending orders; modifying of StopLoss and TakeProfit; undo deletion; chart print.
Managing the MetaTrader Terminal via DLL
Managing the MetaTrader Terminal via DLL

Managing the MetaTrader Terminal via DLL

The article deals with managing MetaTrader user interface elements via an auxiliary DLL library using the example of changing push notification delivery settings. The library source code and the sample script are attached to the article.
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
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.
Fuzzy logic to create manual trading strategies
Fuzzy logic to create manual trading strategies

Fuzzy logic to create manual trading strategies

This article suggests the ways of improving manual trading strategy by applying fuzzy set theory. As an example we have provided a step-by-step description of the strategy search and the selection of its parameters, followed by fuzzy logic application to blur overly formal criteria for the market entry. This way, after strategy modification we obtain flexible conditions for opening a position that has a reasonable reaction to a market situation.
MetaTrader 4 Expert Advisor exchanges information with the outside world
MetaTrader 4 Expert Advisor exchanges information with the outside world

MetaTrader 4 Expert Advisor exchanges information with the outside world

A simple, universal and reliable solution of information exchange between МetaТrader 4 Expert Advisor and the outside world. Suppliers and consumers of the information can be located on different computers, the connection is performed through the global IP addresses.
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.
My First "Grail"
My First "Grail"

My First "Grail"

Examined are the most frequent mistakes that lead the first-time programmers to creation of a "super-moneymaking" (when tested) trading systems. Exemplary experts that show fantastic results in tester, but result in losses during real trading are presented.
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization

Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization

This article dwells on implementation algorithm of simplest trading systems. The article will be useful for beginning traders and EA writers.
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.
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.
Upgrade to MetaTrader 4 Build 600 and Higher
Upgrade to MetaTrader 4 Build 600 and Higher

Upgrade to MetaTrader 4 Build 600 and Higher

The new version of the MetaTrader 4 terminal features the updated structure of user data storage. In earlier versions all programs, templates, profiles etc. were stored directly in terminal installation folder. Now all necessary data required for a particular user are stored in a separate directory called data folder. Read the article to find answers to frequently asked questions.
Testing Features and Limits in MetaTrader 4
Testing Features and Limits in MetaTrader 4

Testing Features and Limits in MetaTrader 4

This article allows to find out more about features and limits of Strategy Tester in MetaTrader 4.
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.
Using text files for storing input parameters of Expert Advisors, indicators and scripts
Using text files for storing input parameters of Expert Advisors, indicators and scripts

Using text files for storing input parameters of Expert Advisors, indicators and scripts

The article describes the application of text files for storing dynamic objects, arrays and other variables used as properties of Expert Advisors, indicators and scripts. The files serve as a convenient addition to the functionality of standard tools offered by MQL languages.
Features of Custom Indicators Creation
Features of Custom Indicators Creation

Features of Custom Indicators Creation

Creation of Custom Indicators in the MetaTrader trading system has a number of features.
Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?
Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?

Why Is It Important to Update MetaTrader 4 to the Latest Build by August 1?

From August 1, 2014, MetaTrader 4 desktop terminals older than build 600 will no longer be supported. However, many traders still work with outdated versions and are unaware of the updated platform's features. We have put a lot of effort into development and would like to move on with traders and abandon the older builds. In this article, we will describe the advantages of the new MetaTrader 4.
To Sleep, or Not to Sleep?
To Sleep, or Not to Sleep?

To Sleep, or Not to Sleep?

An alternative use of the Sleep() function in the realization of pauses between EA's actions is proposed. The approach under consideration allows a smart use of machine time.
Thomas DeMark's contribution to technical analysis
Thomas DeMark's contribution to technical analysis

Thomas DeMark's contribution to technical analysis

The article details TD points and TD lines discovered by Thomas DeMark. Their practical implementation is revealed. In addition to that, a process of writing three indicators and two Expert Advisors using the concepts of Thomas DeMark is demonstrated.
Secrets of MetaTrader 4 Client Terminal: Alerting System
Secrets of MetaTrader 4 Client Terminal: Alerting System

Secrets of MetaTrader 4 Client Terminal: Alerting System

How to be aware of what happens in the terminal and on your account without permanent looking at the monitor. System events; custom events; wave and executable files; electronic messages; setting up SMTP server access; publications; setting up FTP server access.
Working with Doubles in MQL4
Working with Doubles in MQL4

Working with Doubles in MQL4

In this note we will consider a typical programming errors, that occurs while working with double numbers in MQL4 programs.
Individual Psychology of a Trader
Individual Psychology of a Trader

Individual Psychology of a Trader

A portrait of a trader's behavior on the financial market. Author's own menu from the book "Как играть и выигрывать на бирже" ("How to speculate on stock exchange and win") by A. Elder.
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 Tactics on Forex
Trading Tactics on Forex

Trading Tactics on Forex

The article will help a beginning trader to develop trading tactics on FOREX.
Break Through The Strategy Tester Limit On Testing Hedge EA
Break Through The Strategy Tester Limit On Testing Hedge EA

Break Through The Strategy Tester Limit On Testing Hedge EA

An idea of testing the hedge Expert Advisors using the strategy tester.
Enhancing the StrategyTester to Optimize Indicators Solely on the Example of Flat and Trend Markets
Enhancing the StrategyTester to Optimize Indicators Solely on the Example of Flat and Trend Markets

Enhancing the StrategyTester to Optimize Indicators Solely on the Example of Flat and Trend Markets

It is essential to detect whether a market is flat or not for many strategies. Using the well known ADX we demonstrate how we can use the Strategy Tester not only to optimize this indicator for our specific purpose, but as well we can decide whether this indicator will meet our needs and get to know the average range of the flat and trend markets which might be quite important to determine stops and targets of the markets.
Testing Visualization: Manual Trading
Testing Visualization: Manual Trading

Testing Visualization: Manual Trading

Testing manual strategies on history. Check how your trading algorithm works turning a deaf ear to programming niceties!
Integrating MetaTrader 4  Client Terminal with MS SQL Server
Integrating MetaTrader 4  Client Terminal with MS SQL Server

Integrating MetaTrader 4 Client Terminal with MS SQL Server

The article gives an example of integrating MetaTrader 4 Client Terminal with MS SQL Server using a dll. Attached are both source codes in С++ and in MQL4, and a ready-made and compiled Visual C++ 6.0 SP5 project.
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.
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.
Genetic Algorithms: Mathematics
Genetic Algorithms: Mathematics

Genetic Algorithms: Mathematics

Genetic (evolutionary) algorithms are used for optimization purposes. An example of such purpose can be neuronet learning, i.e., selection of such weight values that allow reaching the minimum error. At this, the genetic algorithm is based on the random search method.
How to Evaluate the Expert Testing Results
How to Evaluate the Expert Testing Results

How to Evaluate the Expert Testing Results

The article gives formulas and the calculation order for data shown in the Tester report.