In previous articles of this series, we laid the groundwork for building a MetaTrader 5–like strategy tester from scratch. With the core structure in place, several critical components are still missing in our project.
To this stage, we are yet to process ticks and bars sequentially, we lack mechanisms for monitoring open orders and the simulated trading account, and we do not have performance metrics such as profit and loss, drawdown, win rate, risk–reward ratios, and detailed trade statistics in the simulator.
In this fascinating article, we build our very first trading robot in the simulator and run a strategy testing action that resembles how the MetaTrader 5 strategy tester works, then compare the outcome produced in a custom simulation against our favorite terminal.
In the previous article, we were able to utilize real ticks, generated ticks, and bars obtained from the MetaTrader 5 terminal in our custom strategy tester. Despite ending up with a first successful strategy tester action, we are yet to fully handle and process data across various instruments and timeframes (something the MetaTrader 5 strategy tester does really well).
This article presents a MetaTrader 5–compatible backtesting workflow that scales across symbols and timeframes. We use HistoryManager to parallelize data collection, synchronize bars and ticks from all timeframes, and run symbol‑isolated OnTick handlers in threads. You will learn how modelling modes affect speed/accuracy, when to rely on terminal data, how to reduce I/O with event‑driven updates, and how to assemble a complete multicurrency trading robot.
Quantitative trend analysis is an approach that transforms chaotic market movements into an orderly system of numbers and patterns. In a world where most traders rely on intuition and visual assessment of charts, mathematical analysis of trend movements provides an undeniable advantage. Instead of subjective feelings, you receive precise data: the average trend duration in days, its typical value in points, and characteristic patterns of development and completion.
It is this objectivity that makes quantitative analysis the cornerstone of professional trading. William Eckhardt, a famous trader, rightly noted that trading is not a field of psychology, but a field of statistics. When you know that uptrends on the EURUSD pair statistically last longer than downtrends, or that 70% of trends on GBPUSD end before reaching 200 points, this is not just information, but a specific guide to action.
What is quantitative trend analysis in the Forex market? We collect statistics on trends, their magnitude and distribution across the EURUSD currency pair. How quantitative trend analysis can help you create a profitable trading expert advisor.
The proposed approach combines COT/TFF data and market quotes into a single Python model with automated trading via MetaTrader 5. This allows us to move from analysis to action without delays and human intervention.
Let's try mining CFTC data, downloading COT and TFF reports via Python, connecting all this with MetaTrader 5 quotes and an AI model, and get forecasts. What are COT reports in the Forex market? How to use COT and TFF reports for forecasting?
The article demonstrates how Python and MetaTrader 5 integration combines research flexibility and trade execution into a single workflow. Python is used for data analysis, feature selection and model training, while MetaTrader 5 is used for testing and trading automation. This approach simplifies the transfer of solutions into practice, increases reproducibility, and makes the development of trading systems faster and more structured.
Four production problems in the pipeline are addressed explicitly: loading multi-year tick data without exceeding memory (partitioned Parquet storage read via Dask), cleaning broker-feed artifacts that corrupt bar construction (zero spreads, duplicate timestamps, NaT indices), calibrating the adaptive threshold for imbalance bars automatically so the first bar does not bias the EWM history, and persisting the EWM tracker across EA restarts so the threshold does not reset mid-session. A short parity test at the end verifies that the two implementations, fed the same tick stream, produce identical bars.
The article replaces clock-based sampling with López de Prado's alternative bar types and provides two aligned implementations: a unified Python module for batch tick histories and an object‑oriented MQL5 library for live EAs. It covers Parquet/Dask infrastructure, data cleaning, and a single API. Practical issues are solved explicitly: zero‑tick time‑bar filtering, imbalance threshold initialization, EWM state persistence, and parity between Python and MQL5 outputs.
Over the decades of its existence, the IMF has accumulated a unique database covering economic indicators of 190 countries. This data includes not only traditional metrics like GDP and inflation, but also complex structural indicators that allow us to see the real state of economies long before markets begin to react. The problem is that this data is presented in raw form and requires significant processing to become of practical value.
Downloading international monetary fund data in Python: Mining IMF data for use in macroeconomic currency strategies. How can macroeconomics help an ordinary and an algorithmic trader?
This article presents an original approach to identifying and classifying fractal patterns. The analysis will be conducted in Python, with the ability to export final models to the MetaTrader 5 terminal in ONNX format.
In this article, we will touch upon the intriguing topic of fractal analysis and market forecasting using machine learning. These are just the first steps towards exploring the diverse fractal structures that form on financial price charts. We will use the correlation to find patterns and the CatBoost algorithm to classify these patterns.
The preceding articles in this series treated time as a feature in its own right: fractional differentiation preserves memory across a stationary series, and cyclical encoding embeds the Fourier structure of the trading calendar into the feature matrix. Both operate on bar-level data. Microstructural features work differently. They treat each bar not as a single observation but as a compressed summary of many individual trades, and they ask what those trades reveal about the market's internal state at the moment the bar closed.
This article implements the Chapter 19 microstructure suite in afml.features.microstructure and explains a two-layer design for OHLCV-only and tick-augmented workflows. We cover Roll and Corwin–Schultz spread/volatility, Kyle's, Amihud's, and Hasbrouck's lambdas, VPIN, and bar‑level imbalance features, all in Numba‑accelerated kernels. A single np.searchsorted pass resolves bar boundaries, enabling prange parallelization and producing a bar‑indexed feature matrix ready for downstream ML models.
In this article, AI is not considered as a magical Make Money button, but as a layer that enhances analysis, helps formalize trading ideas, and integrates into verifiable algorithmic logic. The main goal is to show MetaTrader 5 as an infrastructure where AI progresses from a hypothesis into a controllable trading robot.
MetaTrader 5 is well suited for AI trading because it combines market data, MQL5 development, Python research, ONNX models, Strategy Tester, VPS, and the MQL5.community ecosystem into a single workflow. This article demonstrates a practical path from AI prompts to structured signals, working with code via the AI Assistant in MetaEditor, a quality model, a custom-created Expert Advisor, testing, and a controllable launch of a trading system.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Python-MetaTrader 5 Strategy Tester (Part 04): Tester 101
In previous articles of this series, we laid the groundwork for building a MetaTrader 5–like strategy tester from scratch. With the core structure in place, several critical components are still missing in our project.
To this stage, we are yet to process ticks and bars sequentially, we lack mechanisms for monitoring open orders and the simulated trading account, and we do not have performance metrics such as profit and loss, drawdown, win rate, risk–reward ratios, and detailed trade statistics in the simulator.
Python-MetaTrader 5 Strategy Tester (Part 05): Multi-Symbols and Timeframes Strategy Tester
Quantitative Analysis of Trends: Collecting Statistics in Python
Quantitative trend analysis is an approach that transforms chaotic market movements into an orderly system of numbers and patterns. In a world where most traders rely on intuition and visual assessment of charts, mathematical analysis of trend movements provides an undeniable advantage. Instead of subjective feelings, you receive precise data: the average trend duration in days, its typical value in points, and characteristic patterns of development and completion.
It is this objectivity that makes quantitative analysis the cornerstone of professional trading. William Eckhardt, a famous trader, rightly noted that trading is not a field of psychology, but a field of statistics. When you know that uptrends on the EURUSD pair statistically last longer than downtrends, or that 70% of trends on GBPUSD end before reaching 200 points, this is not just information, but a specific guide to action.
CFTC Data Mining in Python and Building an AI Model
The proposed approach combines COT/TFF data and market quotes into a single Python model with automated trading via MetaTrader 5. This allows us to move from analysis to action without delays and human intervention.
Python + MetaTrader 5: Fast Research Framework for Data, Features, and Prototypes
In this article, we will show:
This will allow us to move from a research experiment to practical implementation in a trading system.
Beyond the Clock (Part 1): Building Activity and Imbalance Bars in Python and MQL5
Downloading International Monetary Fund Data Using Python
Detecting and Classifying Fractal Patterns Using Machine Learning
This article presents an original approach to identifying and classifying fractal patterns. The analysis will be conducted in Python, with the ability to export final models to the MetaTrader 5 terminal in ONNX format.
Feature Engineering for ML (Part 5): Microstructural Features in Python
Why MetaTrader 5 Is the Ideal Platform for AI Trading: MQL5 + Python + ONNX + AI Assistant in a Unified Algorithmic Trading Ecosystem