Articles on strategy testing in MQL5

icon

How to develop, write and test a trading strategy, how to find the optimal system parameters and how to analyze the results? The MetaTrader platform offers developers of trading robots rich functionality for fast and accurate testing of trading ideas. Read these articles to learn how to test multi-currency robots and how to use MQL5 Cloud Network for optimization purposes.

Developers of automated trading systems are recommended to start with the testing fundamentals and tick generation algorithms in the strategy tester.

Add a new article
latest | best
preview
Atmosphere Clouds Model Optimization (ACMO): Practice

Atmosphere Clouds Model Optimization (ACMO): Practice

In this article, we will continue diving into the implementation of the ACMO (Atmospheric Cloud Model Optimization) algorithm. In particular, we will discuss two key aspects: the movement of clouds into low-pressure regions and the rain simulation, including the initialization of droplets and their distribution among clouds. We will also look at other methods that play an important role in managing the state of clouds and ensuring their interaction with the environment.
preview
Developing a Replay System (Part 65): Playing the service (VI)

Developing a Replay System (Part 65): Playing the service (VI)

In this article, we will look at how to implement and solve the mouse pointer issue when using it in conjunction with a replay/simulation application. The content presented here is intended solely for educational purposes. Under no circumstances should the application be viewed for any purpose other than to learn and master the concepts presented.
preview
Trading with the MQL5 Economic Calendar (Part 7): Preparing for Strategy Testing with Resource-Based News Event Analysis

Trading with the MQL5 Economic Calendar (Part 7): Preparing for Strategy Testing with Resource-Based News Event Analysis

In this article, we prepare our MQL5 trading system for strategy testing by embedding economic calendar data as a resource for non-live analysis. We implement event loading and filtering for time, currency, and impact, then validate it in the Strategy Tester. This enables effective backtesting of news-driven strategies.
preview
From Novice to Expert: Programming Candlesticks

From Novice to Expert: Programming Candlesticks

In this article, we take the first step in MQL5 programming, even for complete beginners. We'll show you how to transform familiar candlestick patterns into a fully functional custom indicator. Candlestick patterns are valuable as they reflect real price action and signal market shifts. Instead of manually scanning charts—an approach prone to errors and inefficiencies—we'll discuss how to automate the process with an indicator that identifies and labels patterns for you. Along the way, we’ll explore key concepts like indexing, time series, Average True Range (for accuracy in varying market volatility), and the development of a custom reusable Candlestick Pattern library for use in future projects.
preview
Formulating Dynamic Multi-Pair EA (Part 2): Portfolio Diversification and Optimization

Formulating Dynamic Multi-Pair EA (Part 2): Portfolio Diversification and Optimization

Portfolio Diversification and Optimization strategically spreads investments across multiple assets to minimize risk while selecting the ideal asset mix to maximize returns based on risk-adjusted performance metrics.
preview
Manual Backtesting Made Easy: Building a Custom Toolkit for Strategy Tester in MQL5

Manual Backtesting Made Easy: Building a Custom Toolkit for Strategy Tester in MQL5

In this article, we design a custom MQL5 toolkit for easy manual backtesting in the Strategy Tester. We explain its design and implementation, focusing on interactive trade controls. We then show how to use it to test strategies effectively
preview
Developing a Replay System (Part 64): Playing the service (V)

Developing a Replay System (Part 64): Playing the service (V)

In this article, we will look at how to fix two errors in the code. However, I will try to explain them in a way that will help you, beginner programmers, understand that things don't always go as you expect. Anyway, this is an opportunity to learn. The content presented here is intended solely for educational purposes. In no way should this application be considered as a final document with any purpose other than to explore the concepts presented.
preview
Developing a multi-currency Expert Advisor (Part 18): Automating group selection considering forward period

Developing a multi-currency Expert Advisor (Part 18): Automating group selection considering forward period

Let's continue to automate the steps we previously performed manually. This time we will return to the automation of the second stage, that is, the selection of the optimal group of single instances of trading strategies, supplementing it with the ability to take into account the results of instances in the forward period.
preview
Developing a Replay System (Part 63): Playing the service (IV)

Developing a Replay System (Part 63): Playing the service (IV)

In this article, we will finally solve the problems with the simulation of ticks on a one-minute bar so that they can coexist with real ticks. This will help us avoid problems in the future. The material presented here is for educational purposes only. Under no circumstances should the application be viewed for any purpose other than to learn and master the concepts presented.
preview
Developing a Trading System Based on the Order Book (Part I): Indicator

Developing a Trading System Based on the Order Book (Part I): Indicator

Depth of Market is undoubtedly a very important element for executing fast trades, especially in High Frequency Trading (HFT) algorithms. In this series of articles, we will look at this type of trading events that can be obtained through a broker on many tradable symbols. We will start with an indicator, where you can customize the color palette, position and size of the histogram displayed directly on the chart. We will also look at how to generate BookEvent events to test the indicator under certain conditions. Other possible topics for future articles include how to store price distribution data and how to use it in a strategy tester.
preview
Atmosphere Clouds Model Optimization (ACMO): Theory

Atmosphere Clouds Model Optimization (ACMO): Theory

The article is devoted to the metaheuristic Atmosphere Clouds Model Optimization (ACMO) algorithm, which simulates the behavior of clouds to solve optimization problems. The algorithm uses the principles of cloud generation, movement and propagation, adapting to the "weather conditions" in the solution space. The article reveals how the algorithm's meteorological simulation finds optimal solutions in a complex possibility space and describes in detail the stages of ACMO operation, including "sky" preparation, cloud birth, cloud movement, and rain concentration.
preview
Quantitative approach to risk management: Applying VaR model to optimize multi-currency portfolio using Python and MetaTrader 5

Quantitative approach to risk management: Applying VaR model to optimize multi-currency portfolio using Python and MetaTrader 5

This article explores the potential of the Value at Risk (VaR) model for multi-currency portfolio optimization. Using the power of Python and the functionality of MetaTrader 5, we demonstrate how to implement VaR analysis for efficient capital allocation and position management. From theoretical foundations to practical implementation, the article covers all aspects of applying one of the most robust risk calculation systems – VaR – in algorithmic trading.
preview
Advanced Memory Management and Optimization Techniques in MQL5

Advanced Memory Management and Optimization Techniques in MQL5

Discover practical techniques to optimize memory usage in MQL5 trading systems. Learn to build efficient, stable, and fast-performing Expert Advisors and indicators. We’ll explore how memory really works in MQL5, the common traps that slow your systems down or cause them to fail, and — most importantly — how to fix them.
preview
Archery Algorithm (AA)

Archery Algorithm (AA)

The article takes a detailed look at the archery-inspired optimization algorithm, with an emphasis on using the roulette method as a mechanism for selecting promising areas for "arrows". The method allows evaluating the quality of solutions and selecting the most promising positions for further study.
preview
Developing a Replay System (Part 62): Playing the service (III)

Developing a Replay System (Part 62): Playing the service (III)

In this article, we will begin to address the issue of tick excess that can impact application performance when using real data. This excess often interferes with the correct timing required to construct a one-minute bar in the appropriate window.
preview
Bacterial Chemotaxis Optimization (BCO)

Bacterial Chemotaxis Optimization (BCO)

The article presents the original version of the Bacterial Chemotaxis Optimization (BCO) algorithm and its modified version. We will take a closer look at all the differences, with a special focus on the new version of BCOm, which simplifies the bacterial movement mechanism, reduces the dependence on positional history, and uses simpler math than the computationally heavy original version. We will also conduct the tests and summarize the results.
preview
Developing a Replay System (Part 61): Playing the service (II)

Developing a Replay System (Part 61): Playing the service (II)

In this article, we will look at changes that will allow the replay/simulation system to operate more efficiently and securely. I will also not leave without attention those who want to get the most out of using classes. In addition, we will consider a specific problem in MQL5 that reduces code performance when working with classes, and explain how to solve it.
preview
A New Approach to Custom Criteria in Optimizations (Part 1): Examples of Activation Functions

A New Approach to Custom Criteria in Optimizations (Part 1): Examples of Activation Functions

The first of a series of articles looking at the mathematics of Custom Criteria with a specific focus on non-linear functions used in Neural Networks, MQL5 code for implementation and the use of targeted and correctional offsets.
preview
Tabu Search (TS)

Tabu Search (TS)

The article discusses the Tabu Search algorithm, one of the first and most well-known metaheuristic methods. We will go through the algorithm operation in detail, starting with choosing an initial solution and exploring neighboring options, with an emphasis on using a tabu list. The article covers the key aspects of the algorithm and its features.
preview
Developing a multi-currency Expert Advisor (Part 17): Further preparation for real trading

Developing a multi-currency Expert Advisor (Part 17): Further preparation for real trading

Currently, our EA uses the database to obtain initialization strings for single instances of trading strategies. However, the database is quite large and contains a lot of information that is not needed for the actual EA operation. Let's try to ensure the EA's functionality without a mandatory connection to the database.
preview
Developing a Replay System (Part 60): Playing the Service (I)

Developing a Replay System (Part 60): Playing the Service (I)

We have been working on just the indicators for a long time now, but now it's time to get the service working again and see how the chart is built based on the data provided. However, since the whole thing is not that simple, we will have to be attentive to understand what awaits us ahead.
preview
William Gann methods (Part III): Does Astrology Work?

William Gann methods (Part III): Does Astrology Work?

Do the positions of planets and stars affect financial markets? Let's arm ourselves with statistics and big data, and embark on an exciting journey into the world where stars and stock charts intersect.
preview
Artificial Algae Algorithm (AAA)

Artificial Algae Algorithm (AAA)

The article considers the Artificial Algae Algorithm (AAA) based on biological processes characteristic of microalgae. The algorithm includes spiral motion, evolutionary process and adaptation, which allows it to solve optimization problems. The article provides an in-depth analysis of the working principles of AAA and its potential in mathematical modeling, highlighting the connection between nature and algorithmic solutions.
preview
William Gann methods (Part II): Creating Gann Square indicator

William Gann methods (Part II): Creating Gann Square indicator

We will create an indicator based on the Gann's Square of 9, built by squaring time and price. We will prepare the code and test the indicator in the platform on different time intervals.
preview
Animal Migration Optimization (AMO) algorithm

Animal Migration Optimization (AMO) algorithm

The article is devoted to the AMO algorithm, which models the seasonal migration of animals in search of optimal conditions for life and reproduction. The main features of AMO include the use of topological neighborhood and a probabilistic update mechanism, which makes it easy to implement and flexible for various optimization tasks.
preview
Developing a Replay System (Part 59): A New Future

Developing a Replay System (Part 59): A New Future

Having a proper understanding of different ideas allows us to do more with less effort. In this article, we'll look at why it's necessary to configure a template before the service can interact with the chart. Also, what if we improve the mouse pointer so we can do more things with it?
preview
Robustness Testing on Expert Advisors

Robustness Testing on Expert Advisors

In strategy development, there are many intricate details to consider, many of which are not highlighted for beginner traders. As a result, many traders, myself included, have had to learn these lessons the hard way. This article is based on my observations of common pitfalls that most beginner traders encounter when developing strategies on MQL5. It will offer a range of tips, tricks, and examples to help identify the disqualification of an EA and test the robustness of our own EAs in an easy-to-implement way. The goal is to educate readers, helping them avoid future scams when purchasing EAs as well as preventing mistakes in their own strategy development.
preview
Artificial Bee Hive Algorithm (ABHA): Tests and results

Artificial Bee Hive Algorithm (ABHA): Tests and results

In this article, we will continue exploring the Artificial Bee Hive Algorithm (ABHA) by diving into the code and considering the remaining methods. As you might remember, each bee in the model is represented as an individual agent whose behavior depends on internal and external information, as well as motivational state. We will test the algorithm on various functions and summarize the results by presenting them in the rating table.
preview
Developing a Replay System (Part 58): Returning to Work on the Service

Developing a Replay System (Part 58): Returning to Work on the Service

After a break in development and improvement of the service used for replay/simulator, we are resuming work on it. Now that we've abandoned the use of resources like terminal globals, we'll have to completely restructure some parts of it. Don't worry, this process will be explained in detail so that everyone can follow the development of our service.
preview
Custom Indicator: Plotting Partial Entry, Exit and Reversal Deals for Netting Accounts

Custom Indicator: Plotting Partial Entry, Exit and Reversal Deals for Netting Accounts

In this article, we will look at a non-standard way of creating an indicator in MQL5. Instead of focusing on a trend or chart pattern, our goal will be to manage our own positions, including partial entries and exits. We will make extensive use of dynamic matrices and some trading functions related to trade history and open positions to indicate on the chart where these trades were made.
preview
Developing a Replay System (Part 57): Understanding a Test Service

Developing a Replay System (Part 57): Understanding a Test Service

One point to note: although the service code is not included in this article and will only be provided in the next one, I'll explain it since we'll be using that same code as a springboard for what we're actually developing. So, be attentive and patient. Wait for the next article, because every day everything becomes more interesting.
preview
Developing a multi-currency Expert Advisor (Part 16): Impact of different quote histories on test results

Developing a multi-currency Expert Advisor (Part 16): Impact of different quote histories on test results

The EA under development is expected to show good results when trading with different brokers. But for now we have been using quotes from a MetaQuotes demo account to perform tests. Let's see if our EA is ready to work on a trading account with different quotes compared to those used during testing and optimization.
preview
Chaos theory in trading (Part 1): Introduction, application in financial markets and Lyapunov exponent

Chaos theory in trading (Part 1): Introduction, application in financial markets and Lyapunov exponent

Can chaos theory be applied to financial markets? In this article, we will consider how conventional Chaos theory and chaotic systems are different from the concept proposed by Bill Williams.
preview
Developing a multi-currency Expert Advisor (Part 15): Preparing EA for real trading

Developing a multi-currency Expert Advisor (Part 15): Preparing EA for real trading

As we gradually approach to obtaining a ready-made EA, we need to pay attention to issues that seem secondary at the stage of testing a trading strategy, but become important when moving on to real trading.
preview
Developing a Replay System (Part 56): Adapting the Modules

Developing a Replay System (Part 56): Adapting the Modules

Although the modules already interact with each other properly, an error occurs when trying to use the mouse pointer in the replay service. We need to fix this before moving on to the next step. Additionally, we will fix an issue in the mouse indicator code. So this version will be finally stable and properly polished.
preview
Adaptive Social Behavior Optimization (ASBO): Schwefel, Box-Muller Method

Adaptive Social Behavior Optimization (ASBO): Schwefel, Box-Muller Method

This article provides a fascinating insight into the world of social behavior in living organisms and its influence on the creation of a new mathematical model - ASBO (Adaptive Social Behavior Optimization). We will examine how the principles of leadership, neighborhood, and cooperation observed in living societies inspire the development of innovative optimization algorithms.
preview
Developing a Replay System (Part 55): Control Module

Developing a Replay System (Part 55): Control Module

In this article, we will implement a control indicator so that it can be integrated into the message system we are developing. Although it is not very difficult, there are some details that need to be understood about the initialization of this module. The material presented here is for educational purposes only. In no way should it be considered as an application for any purpose other than learning and mastering the concepts shown.
preview
Artificial Electric Field Algorithm (AEFA)

Artificial Electric Field Algorithm (AEFA)

The article presents an artificial electric field algorithm (AEFA) inspired by Coulomb's law of electrostatic force. The algorithm simulates electrical phenomena to solve complex optimization problems using charged particles and their interactions. AEFA exhibits unique properties in the context of other algorithms related to laws of nature.
preview
Building a Candlestick Trend Constraint Model (Part 10): Strategic Golden and Death Cross (EA)

Building a Candlestick Trend Constraint Model (Part 10): Strategic Golden and Death Cross (EA)

Did you know that the Golden Cross and Death Cross strategies, based on moving average crossovers, are some of the most reliable indicators for identifying long-term market trends? A Golden Cross signals a bullish trend when a shorter moving average crosses above a longer one, while a Death Cross indicates a bearish trend when the shorter average moves below. Despite their simplicity and effectiveness, manually applying these strategies often leads to missed opportunities or delayed trades. By automating them within the Trend Constraint EA using MQL5, these strategies can operate independently to handle market reversals efficiently, while constrained strategies align with broader trends. This approach revolutionizes performance by ensuring precise execution and seamless integration of reversal and trend-following systems.
preview
Developing a Replay System (Part 54): The Birth of the First Module

Developing a Replay System (Part 54): The Birth of the First Module

In this article, we will look at how to put together the first of a number of truly functional modules for use in the replay/simulator system that will also be of general purpose to serve other purposes. We are talking about the mouse module.