Articles on data analysis and statistics in MQL5

icon

Articles on mathematical models and laws of probability are interesting for many traders. Mathematics is the basis of technical indicators, and statistics is required to analyze trading results and develop strategies.

Read about the fuzzy logic, digital filters, market profile, Kohonen maps, neural gas and many other tools that can be used for trading.

Add a new article
latest | best
preview
Creating a Trading Administrator Panel in MQL5 (Part IX): Code Organization (I)

Creating a Trading Administrator Panel in MQL5 (Part IX): Code Organization (I)

This discussion delves into the challenges encountered when working with large codebases. We will explore the best practices for code organization in MQL5 and implement a practical approach to enhance the readability and scalability of our Trading Administrator Panel source code. Additionally, we aim to develop reusable code components that can potentially benefit other developers in their algorithm development. Read on and join the conversation.
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
Price Action Analysis Toolkit Development (Part 11): Heikin Ashi Signal EA

Price Action Analysis Toolkit Development (Part 11): Heikin Ashi Signal EA

MQL5 offers endless opportunities to develop automated trading systems tailored to your preferences. Did you know it can even perform complex mathematical calculations? In this article, we introduce the Japanese Heikin-Ashi technique as an automated trading strategy.
preview
Artificial Bee Hive Algorithm (ABHA): Theory and methods

Artificial Bee Hive Algorithm (ABHA): Theory and methods

In this article, we will consider the Artificial Bee Hive Algorithm (ABHA) developed in 2009. The algorithm is aimed at solving continuous optimization problems. We will look at how ABHA draws inspiration from the behavior of a bee colony, where each bee has a unique role that helps them find resources more efficiently.
preview
Trend Prediction with LSTM for Trend-Following Strategies

Trend Prediction with LSTM for Trend-Following Strategies

Long Short-Term Memory (LSTM) is a type of recurrent neural network (RNN) designed to model sequential data by effectively capturing long-term dependencies and addressing the vanishing gradient problem. In this article, we will explore how to utilize LSTM to predict future trends, enhancing the performance of trend-following strategies. The article will cover the introduction of key concepts and the motivation behind development, fetching data from MetaTrader 5, using that data to train the model in Python, integrating the machine learning model into MQL5, and reflecting on the results and future aspirations based on statistical backtesting.
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
Chaos theory in trading (Part 2): Diving deeper

Chaos theory in trading (Part 2): Diving deeper

We continue our dive into chaos theory in financial markets. This time I will consider its applicability to the analysis of currencies and other assets.
preview
Data Science and ML (Part 33): Pandas Dataframe in MQL5, Data Collection for ML Usage made easier

Data Science and ML (Part 33): Pandas Dataframe in MQL5, Data Collection for ML Usage made easier

When working with machine learning models, it’s essential to ensure consistency in the data used for training, validation, and testing. In this article, we will create our own version of the Pandas library in MQL5 to ensure a unified approach for handling machine learning data, for ensuring the same data is applied inside and outside MQL5, where most of the training occurs.
preview
Price Action Analysis Toolkit Development (Part 10): External Flow (II) VWAP

Price Action Analysis Toolkit Development (Part 10): External Flow (II) VWAP

Master the power of VWAP with our comprehensive guide! Learn how to integrate VWAP analysis into your trading strategy using MQL5 and Python. Maximize your market insights and improve your trading decisions today.
preview
Gating mechanisms in ensemble learning

Gating mechanisms in ensemble learning

In this article, we continue our exploration of ensemble models by discussing the concept of gates, specifically how they may be useful in combining model outputs to enhance either prediction accuracy or model generalization.
preview
Redefining MQL5 and MetaTrader 5 Indicators

Redefining MQL5 and MetaTrader 5 Indicators

An innovative approach to collecting indicator information in MQL5 enables more flexible and streamlined data analysis by allowing developers to pass custom inputs to indicators for immediate calculations. This approach is particularly useful for algorithmic trading, as it provides enhanced control over the information processed by indicators, moving beyond traditional constraints.
preview
Price Action Analysis Toolkit Development (Part 9): External Flow

Price Action Analysis Toolkit Development (Part 9): External Flow

This article explores a new dimension of analysis using external libraries specifically designed for advanced analytics. These libraries, like pandas, provide powerful tools for processing and interpreting complex data, enabling traders to gain more profound insights into market dynamics. By integrating such technologies, we can bridge the gap between raw data and actionable strategies. Join us as we lay the foundation for this innovative approach and unlock the potential of combining technology with trading expertise.
preview
MQL5 Trading Toolkit (Part 7): Expanding the History Management EX5 Library with the Last Canceled Pending Order Functions

MQL5 Trading Toolkit (Part 7): Expanding the History Management EX5 Library with the Last Canceled Pending Order Functions

Learn how to complete the creation of the final module in the History Manager EX5 library, focusing on the functions responsible for handling the most recently canceled pending order. This will provide you with the tools to efficiently retrieve and store key details related to canceled pending orders with MQL5.
preview
Adaptive Social Behavior Optimization (ASBO): Two-phase evolution

Adaptive Social Behavior Optimization (ASBO): Two-phase evolution

We continue dwelling on the topic of social behavior of living organisms and its impact on the development of a new mathematical model - ASBO (Adaptive Social Behavior Optimization). We will dive into the two-phase evolution, test the algorithm and draw conclusions. Just as in nature a group of living organisms join their efforts to survive, ASBO uses principles of collective behavior to solve complex optimization problems.
preview
Integration of Broker APIs with Expert Advisors using MQL5 and Python

Integration of Broker APIs with Expert Advisors using MQL5 and Python

In this article, we will discuss the implementation of MQL5 in partnership with Python to perform broker-related operations. Imagine having a continuously running Expert Advisor (EA) hosted on a VPS, executing trades on your behalf. At some point, the ability of the EA to manage funds becomes paramount. This includes operations such as topping up your trading account and initiating withdrawals. In this discussion, we will shed light on the advantages and practical implementation of these features, ensuring seamless integration of fund management into your trading strategy. Stay tuned!
preview
Hidden Markov Models for Trend-Following Volatility Prediction

Hidden Markov Models for Trend-Following Volatility Prediction

Hidden Markov Models (HMMs) are powerful statistical tools that identify underlying market states by analyzing observable price movements. In trading, HMMs enhance volatility prediction and inform trend-following strategies by modeling and anticipating shifts in market regimes. In this article, we will present the complete procedure for developing a trend-following strategy that utilizes HMMs to predict volatility as a filter.
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
MQL5 Trading Toolkit (Part 6): Expanding the History Management EX5 Library with the Last Filled Pending Order Functions

MQL5 Trading Toolkit (Part 6): Expanding the History Management EX5 Library with the Last Filled Pending Order Functions

Learn how to create an EX5 module of exportable functions that seamlessly query and save data for the most recently filled pending order. In this comprehensive step-by-step guide, we will enhance the History Management EX5 library by developing dedicated and compartmentalized functions to retrieve essential properties of the last filled pending order. These properties include the order type, setup time, execution time, filling type, and other critical details necessary for effective pending orders trade history management and analysis.
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
Developing A Swing Entries Monitoring (EA)

Developing A Swing Entries Monitoring (EA)

As the year approaches its end, long-term traders often reflect on market history to analyze its behavior and trends, aiming to project potential future movements. In this article, we will explore the development of a long-term entry monitoring Expert Advisor (EA) using MQL5. The objective is to address the challenge of missed long-term trading opportunities caused by manual trading and the absence of automated monitoring systems. We'll use one of the most prominently traded pairs as an example to strategize and develop our solution effectively.
preview
MQL5 Wizard Techniques you should know (Part 52): Accelerator Oscillator

MQL5 Wizard Techniques you should know (Part 52): Accelerator Oscillator

The Accelerator Oscillator is another Bill Williams Indicator that tracks price momentum's acceleration and not just its pace. Although much like the Awesome oscillator we reviewed in a recent article, it seeks to avoid the lagging effects by focusing more on acceleration as opposed to just speed. We examine as always what patterns we can get from this and also what significance each could have in trading via a wizard assembled Expert Advisor.
preview
Ensemble methods to enhance classification tasks in MQL5

Ensemble methods to enhance classification tasks in MQL5

In this article, we present the implementation of several ensemble classifiers in MQL5 and discuss their efficacy in varying situations.
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
News Trading Made Easy (Part 6): Performing Trades (III)

News Trading Made Easy (Part 6): Performing Trades (III)

In this article news filtration for individual news events based on their IDs will be implemented. In addition, previous SQL queries will be improved to provide additional information or reduce the query's runtime. Furthermore, the code built in the previous articles will be made functional.
preview
Forex spread trading using seasonality

Forex spread trading using seasonality

The article examines the possibilities of generating and providing reporting data on the use of the seasonality factor when trading spreads on Forex.
preview
Econometric tools for forecasting volatility: GARCH model

Econometric tools for forecasting volatility: GARCH model

The article describes the properties of the non-linear model of conditional heteroscedasticity (GARCH). The iGARCH indicator has been built on its basis for predicting volatility one step ahead. The ALGLIB numerical analysis library is used to estimate the model parameters.
preview
Price Action Analysis Toolkit Development (Part 6): Mean Reversion Signal Reaper

Price Action Analysis Toolkit Development (Part 6): Mean Reversion Signal Reaper

While some concepts may seem straightforward at first glance, bringing them to life in practice can be quite challenging. In the article below, we'll take you on a journey through our innovative approach to automating an Expert Advisor (EA) that skillfully analyzes the market using a mean reversion strategy. Join us as we unravel the intricacies of this exciting automation process.
preview
MQL5 Trading Toolkit (Part 5): Expanding the History Management EX5 Library with Position Functions

MQL5 Trading Toolkit (Part 5): Expanding the History Management EX5 Library with Position Functions

Discover how to create exportable EX5 functions to efficiently query and save historical position data. In this step-by-step guide, we will expand the History Management EX5 library by developing modules that retrieve key properties of the most recently closed position. These include net profit, trade duration, pip-based stop loss, take profit, profit values, and various other important details.
preview
MQL5 Wizard Techniques you should know (Part 51): Reinforcement Learning with SAC

MQL5 Wizard Techniques you should know (Part 51): Reinforcement Learning with SAC

Soft Actor Critic is a Reinforcement Learning algorithm that utilizes 3 neural networks. An actor network and 2 critic networks. These machine learning models are paired in a master slave partnership where the critics are modelled to improve the forecast accuracy of the actor network. While also introducing ONNX in these series, we explore how these ideas could be put to test as a custom signal of a wizard assembled Expert Advisor.
preview
Integrating MQL5 with data processing packages (Part 4): Big Data Handling

Integrating MQL5 with data processing packages (Part 4): Big Data Handling

Exploring advanced techniques to integrate MQL5 with powerful data processing tools, this part focuses on efficient handling of big data to enhance trading analysis and decision-making.
preview
Across Neighbourhood Search (ANS)

Across Neighbourhood Search (ANS)

The article reveals the potential of the ANS algorithm as an important step in the development of flexible and intelligent optimization methods that can take into account the specifics of the problem and the dynamics of the environment in the search space.
preview
Price Action Analysis Toolkit Development (Part 5): Volatility Navigator EA

Price Action Analysis Toolkit Development (Part 5): Volatility Navigator EA

Determining market direction can be straightforward, but knowing when to enter can be challenging. As part of the series titled "Price Action Analysis Toolkit Development", I am excited to introduce another tool that provides entry points, take profit levels, and stop loss placements. To achieve this, we have utilized the MQL5 programming language. Let’s delve into each step in this article.
preview
Ensemble methods to enhance numerical predictions in MQL5

Ensemble methods to enhance numerical predictions in MQL5

In this article, we present the implementation of several ensemble learning methods in MQL5 and examine their effectiveness across different scenarios.
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.
preview
Portfolio Risk Model using Kelly Criterion and Monte Carlo Simulation

Portfolio Risk Model using Kelly Criterion and Monte Carlo Simulation

For decades, traders have been using the Kelly Criterion formula to determine the optimal proportion of capital to allocate to an investment or bet to maximize long-term growth while minimizing the risk of ruin. However, blindly following Kelly Criterion using the result of a single backtest is often dangerous for individual traders, as in live trading, trading edge diminishes over time, and past performance is no predictor of future result. In this article, I will present a realistic approach to applying the Kelly Criterion for one or more EA's risk allocation in MetaTrader 5, incorporating Monte Carlo simulation results from Python.
preview
Developing a trading robot in Python (Part 3): Implementing a model-based trading algorithm

Developing a trading robot in Python (Part 3): Implementing a model-based trading algorithm

We continue the series of articles on developing a trading robot in Python and MQL5. In this article, we will create a trading algorithm in Python.
preview
MQL5 Trading Toolkit (Part 4): Developing a History Management EX5 Library

MQL5 Trading Toolkit (Part 4): Developing a History Management EX5 Library

Learn how to retrieve, process, classify, sort, analyze, and manage closed positions, orders, and deal histories using MQL5 by creating an expansive History Management EX5 Library in a detailed step-by-step approach.
preview
Utilizing CatBoost Machine Learning model as a Filter for Trend-Following Strategies

Utilizing CatBoost Machine Learning model as a Filter for Trend-Following Strategies

CatBoost is a powerful tree-based machine learning model that specializes in decision-making based on stationary features. Other tree-based models like XGBoost and Random Forest share similar traits in terms of their robustness, ability to handle complex patterns, and interpretability. These models have a wide range of uses, from feature analysis to risk management. In this article, we're going to walk through the procedure of utilizing a trained CatBoost model as a filter for a classic moving average cross trend-following strategy. This article is meant to provide insights into the strategy development process while addressing the challenges one may face along the way. I will introduce my workflow of fetching data from MetaTrader 5, training machine learning model in Python, and integrating back to MetaTrader 5 Expert Advisors. By the end of this article, we will validate the strategy through statistical testing and discuss future aspirations extending from the current approach.
preview
Price Action Analysis Toolkit Development Part (4): Analytics Forecaster EA

Price Action Analysis Toolkit Development Part (4): Analytics Forecaster EA

We are moving beyond simply viewing analyzed metrics on charts to a broader perspective that includes Telegram integration. This enhancement allows important results to be delivered directly to your mobile device via the Telegram app. Join us as we explore this journey together in this article.