Articles on the MQL5 programming and use of trading robots

icon

Expert Advisors created for the MetaTrader platform perform a variety of functions implemented by their developers. Trading robots can track financial symbols 24 hours a day, copy deals, create and send reports, analyze news and even provide specific custom graphical interface.

The articles describe programming techniques, mathematical ideas for data processing, tips on creating and ordering of trading robots.

Add a new article
latest | best
Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio
Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio

Building interactive semi-automatic drag-and-drop Expert Advisor based on predefined risk and R/R ratio

Some traders execute all their trades automatically, and some mix automatic and manual trades based on the output of several indicators. Being a member of the latter group I needed an interactive tool to asses dynamically risk and reward price levels directly from the chart. This article will present a way to implement an interactive semi-automatic Expert Advisor with predefined equity risk and R/R ratio. The Expert Advisor risk, R/R and lot size parameters can be changed during runtime on the EA panel.
Guide to Testing and Optimizing of Expert Advisors in MQL5
Guide to Testing and Optimizing of Expert Advisors in MQL5

Guide to Testing and Optimizing of Expert Advisors in MQL5

This article explains the step by step process of identifying and resolving code errors as well as the steps in testing and optimizing of the Expert Advisor input parameters. You will learn how to use Strategy Tester of MetaTrader 5 client terminal to find the best symbol and set of input parameters for your Expert Advisor.
The "New Bar" Event Handler
The "New Bar" Event Handler

The "New Bar" Event Handler

MQL5 programming language is capable of solving problems on a brand new level. Even those tasks, that already have such solutions, thanks to object oriented programming can rise to a higher level. In this article we take a specially simple example of checking new bar on a chart, that was transformed into rather powerful and versatile tool. What tool? Find out in this article.
Controlling the Slope of Balance Curve During Work of an Expert Advisor
Controlling the Slope of Balance Curve During Work of an Expert Advisor

Controlling the Slope of Balance Curve During Work of an Expert Advisor

Finding rules for a trade system and programming them in an Expert Advisor is a half of the job. Somehow, you need to correct the operation of the Expert Advisor as it accumulates the results of trading. This article describes one of approaches, which allows improving performance of an Expert Advisor through creation of a feedback that measures slope of the balance curve.
Contest of Expert Advisors inside an Expert Advisor
Contest of Expert Advisors inside an Expert Advisor

Contest of Expert Advisors inside an Expert Advisor

Using virtual trading, you can create an adaptive Expert Advisor, which will turn on and off trades at the real market. Combine several strategies in a single Expert Advisor! Your multisystem Expert Advisor will automatically choose a trade strategy, which is the best to trade with at the real market, on the basis of profitability of virtual trades. This kind of approach allows decreasing drawdown and increasing profitability of your work at the market. Experiment and share your results with others! I think many people will be interested to know about your portfolio of strategies.
Using the TesterWithdrawal() Function for Modeling the Withdrawals of Profit
Using the TesterWithdrawal() Function for Modeling the Withdrawals of Profit

Using the TesterWithdrawal() Function for Modeling the Withdrawals of Profit

This article describes the usage of the TesterWithDrawal() function for estimating risks in trade systems which imply the withdrawing of a certain part of assets during their operation. In addition, it describes the effect of this function on the algorithm of calculation of the drawdown of equity in the strategy tester. This function is useful when optimizing parameter of your Expert Advisors.
How to Quickly Create an Expert Advisor for Automated Trading Championship 2010
How to Quickly Create an Expert Advisor for Automated Trading Championship 2010

How to Quickly Create an Expert Advisor for Automated Trading Championship 2010

In order to develop an expert to participate in Automated Trading Championship 2010, let's use a template of ready expert advisor. Even novice MQL5 programmer will be capable of this task, because for your strategies the basic classes, functions, templates are already developed. It's enough to write a minimal amount of code to implement your trading idea.
20 Trade Signals in MQL5
20 Trade Signals in MQL5

20 Trade Signals in MQL5

This article will teach you how to receive trade signals that are necessary for a trade system to work. The examples of forming 20 trade signals are given here as separate custom functions that can be used while developing Expert Advisors. For your convenience, all the functions used in the article are combined in a single mqh include file that can be easily connected to a future Expert Advisor.
The Prototype of a Trading Robot
The Prototype of a Trading Robot

The Prototype of a Trading Robot

This article summarizes and systematizes the principles of creating algorithms and elements of trading systems. The article considers designing of expert algorithm. As an example the CExpertAdvisor class is considered, which can be used for quick and easy development of trading systems.
How to Create Your Own Trailing Stop
How to Create Your Own Trailing Stop

How to Create Your Own Trailing Stop

The basic rule of trader - let profit to grow, cut off losses! This article considers one of the basic techniques, allowing to follow this rule - moving the protective stop level (Stop loss level) after increasing position profit, i.e. - Trailing Stop level. You'll find the step by step procedure to create a class for trailing stop on SAR and NRTR indicators. Everyone will be able to insert this trailing stop into their experts or use it independently to control positions in their accounts.
Limitations and Verifications in Expert Advisors
Limitations and Verifications in Expert Advisors

Limitations and Verifications in Expert Advisors

Is it allowed to trade this symbol on Monday? Is there enough money to open position? How big is the loss if Stop Loss triggers? How to limit the number of pending orders? Was the trade operation executed at the current bar or at the previous one? If a trade robot cannot perform this kind of verifications, then any trade strategy can turn into a losing one. This article shows the examples of verifications that are useful in any Expert Advisor.
The Optimal Method for Calculation of Total Position Volume by Specified Magic Number
The Optimal Method for Calculation of Total Position Volume by Specified Magic Number

The Optimal Method for Calculation of Total Position Volume by Specified Magic Number

The problem of calculation of the total position volume of the specified symbol and magic number is considered in this article. The proposed method requests only the minimum necessary part of the history of deals, finds the closest time when the total position was equal to zero, and performs the calculations with the recent deals. Working with global variables of the client terminal is also considered.
Processing of trade events in Expert Advisor using the OnTrade() function
Processing of trade events in Expert Advisor using the OnTrade() function

Processing of trade events in Expert Advisor using the OnTrade() function

MQL5 gave a mass of innovations, including work with events of various types (timer events, trade events, custom events, etc.). Ability to handle events allows you to create completely new type of programs for automatic and semi-automatic trading. In this article we will consider trade events and write some code for the OnTrade() function, that will process the Trade event.
How to Order a Trading Robot in MQL5 and MQL4
How to Order a Trading Robot in MQL5 and MQL4

How to Order a Trading Robot in MQL5 and MQL4

"Freelance" is the largest freelance service for ordering MQL4/MQL5 trading robots and technical indicators. Hundreds of professional developers are ready to develop a custom trading application for the MetaTrader 4/5 terminal.
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners
Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners

Step-By-Step Guide to writing an Expert Advisor in MQL5 for Beginners

The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.
An Example of a Trading Strategy Based on Timezone Differences on Different Continents
An Example of a Trading Strategy Based on Timezone Differences on Different Continents

An Example of a Trading Strategy Based on Timezone Differences on Different Continents

Surfing the Internet, it is easy to find many strategies, which will give you a number of various recommendations. Let’s take an insider’s approach and look into the process of strategy creation, based on the differences in timezones on different continents.
MQL for "Dummies": How to Design and Construct Object Classes
MQL for "Dummies": How to Design and Construct Object Classes

MQL for "Dummies": How to Design and Construct Object Classes

By creating a sample program of visual design, we demonstrate how to design and construct classes in MQL5. The article is written for beginner programmers, who are working on MT5 applications. We propose a simple and easy grasping technology for creating classes, without the need to deeply immerse into the theory of object-oriented programming.
Creating Active Control Panels in MQL5 for Trading
Creating Active Control Panels in MQL5 for Trading

Creating Active Control Panels in MQL5 for Trading

The article covers the problem of development of active control panels in MQL5. Interface elements are managed by the event handling mechanism. Besides, the option of a flexible setup of control elements properties is available. The active control panel allows working with positions, as well setting, modifying and deleting market and pending orders.
A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment
A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment

A Virtual Order Manager to track orders within the position-centric MetaTrader 5 environment

This class library can be added to an MetaTrader 5 Expert Advisor to enable it to be written with an order-centric approach broadly similar to MetaTrader 4, in comparison to the position-based approach of MetaTrader 5. It does this by keeping track of virtual orders at the MetaTrader 5 client terminal, while maintaining a protective broker stop for each position for disaster protection.
Creating a "Snake" Game in MQL5
Creating a "Snake" Game in MQL5

Creating a "Snake" Game in MQL5

This article describes an example of "Snake" game programming. In MQL5, the game programming became possible primarily due to event handling features. The object-oriented programming greatly simplifies this process. In this article, you will learn the event processing features, the examples of use of the Standard MQL5 Library classes and details of periodic function calls.
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors

MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors

In order to obtain values of a built-in or custom indicator in an Expert Advisor, first its handle should be created using the corresponding function. Examples in the article show how to use this or that technical indicator while creating your own programs. The article describes indicators that are built n the MQL5 language. It is intended for those who don't have much experience in the development of trading strategies and offers simple and clear ways of working with indicators using the offered library of functions.
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.
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.
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.
MQL4  as a Trader's Tool, or The Advanced Technical Analysis
MQL4  as a Trader's Tool, or The Advanced Technical Analysis

MQL4 as a Trader's Tool, or The Advanced Technical Analysis

Trading is, first of all, a calculus of probabilities. The proverb about idleness being an engine for progress reveals us the reason why all those indicators and trading systems have been developed. It comes that the major of newcomers in trading study "ready-made" trading theories. But, as luck would have it, there are some more undiscovered market secrets, and tools used in analyzing of price movements exist, basically, as those unrealized technical indicators or math and stat packages. Thanks awfully to Bill Williams for his contribution to the market movements theory. Though, perhaps, it's too early to rest on oars.
Graphic Expert Advisor: AutoGraf
Graphic Expert Advisor: AutoGraf

Graphic Expert Advisor: AutoGraf

The article shows the workability of graphics in creation of a convenient interface to manage trading.
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.
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.
A Pause between Trades
A Pause between Trades

A Pause between Trades

The article deals with the problem of how to arrange pauses between trade operations when a number of experts work on one МТ 4 Client Terminal. It is intended for users who have basic skills in both working with the terminal and programming in MQL 4.
MagicNumber: "Magic" Identifier of the Order
MagicNumber: "Magic" Identifier of the Order

MagicNumber: "Magic" Identifier of the Order

The article deals with the problem of conflict-free trading of several experts on the same МТ 4 Client Terminal. It "teaches" the expert to manage only "its own" orders without modifying or closing "someone else's" positions (opened manually or by other experts). The article was written for users who have basic skills of working with the terminal and programming in MQL 4.
Working with Files. An Example of Important Market Events Visualization
Working with Files. An Example of Important Market Events Visualization

Working with Files. An Example of Important Market Events Visualization

The article deals with the outlook of using MQL4 for more productive work at FOREX markets.
Error 146 ("Trade context busy") and How to Deal with It
Error 146 ("Trade context busy") and How to Deal with It

Error 146 ("Trade context busy") and How to Deal with It

The article deals with conflict-free trading of several experts on one МТ 4 Client Terminal. It will be useful for those who have basic command of working with the terminal and programming in MQL 4.
Information Storage and View
Information Storage and View

Information Storage and View

The article deals with convenient and efficient methods of information storage and viewing. Alternatives to the terminal standard log file and the Comment() function are considered here.
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.
Expert Advisor Sample
Expert Advisor Sample

Expert Advisor Sample

The principles of MQL4-programs development are shown on sample of creating a simple Expert Advisor system based on the standard MACD indicator.
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.