Articles on trading system automation in MQL5

icon

Read articles on the trading systems with a wide variety of ideas at the core. Learn how to use statistical methods and patterns on candlestick charts, how to filter signals and where to use semaphore indicators.

The MQL5 Wizard will help you create robots without programming to quickly check your trading ideas. Use the Wizard to learn about genetic algorithms.

Add a new article
latest | best
preview
Neural Networks in Trading: An Intelligent Forecast Pipeline (Sparse Mixture of experts)

Neural Networks in Trading: An Intelligent Forecast Pipeline (Sparse Mixture of experts)

We invite you to explore the practical implementation of a sparse mixture of experts block for time series in the OpenCL computing environment. This article provides a step-by-step explanation of how masked multi-window convolution works, as well as how gradient-based training is organized in the presence of multiple information streams.
preview
Elite Crystal Evolution Algorithm (CEO-inspired): Theory

Elite Crystal Evolution Algorithm (CEO-inspired): Theory

A new original population-based algorithm, ECEA, is presented. Inspired by the process of water freezing, it adapts ideas from the Crystal Energy Optimizer (CEO) algorithm, which uses graph-based search, for general optimization problems. The algorithm uses a dynamic elite group, three search strategies, and a periodic diversification mechanism.
preview
Unified Multi-Timeframe Renko: Synthesizing the Market's Temporal Dimensions

Unified Multi-Timeframe Renko: Synthesizing the Market's Temporal Dimensions

The article presents an innovative concept for a multi-timeframe Renko chart that combines signals from four timeframes (M5, M15, H1, H4) into a unified synthetic instrument. The system creates a virtual symbol in MetaTrader 5 by using the EMA of each timeframe to generate a composite signal through three methods: simple average, weighted average, and consensus. The implementation includes ATR-based adaptive brick sizing, real-time operation, and full integration with MetaTrader 5.
preview
Designing a Unified Order Execution Gateway Class in MQL5

Designing a Unified Order Execution Gateway Class in MQL5

This class provides one point of contact for trade operations in MQL5. It rounds and clamps lot sizes, validates SL/TP against the broker's minimum distance, resolves a compatible filling policy, and applies bounded retries for transient retcodes. Calls return a structured CGatewayResult instead of raw retcodes, simplifying error handling and maintenance across strategies.
preview
From Novice to Expert: Systematic Profit Conservation Using Candle Range Theory

From Novice to Expert: Systematic Profit Conservation Using Candle Range Theory

A hybrid exit engine for MQL5 replaces static TPs with CRT-derived structural levels. The CRT_ProfitConserve class secures a partial at the first level and then trails the remaining position by structural anchors rather than fixed pips. The article walks through the class API, essential methods, and example usage in EAs, providing a clear path to embed CRT-based exits into existing strategies.
preview
Automating Trading Strategies in MQL5 (Part 52): The tCISD Model with SSMT and Quarterly Theory

Automating Trading Strategies in MQL5 (Part 52): The tCISD Model with SSMT and Quarterly Theory

We build a tCISD program in MQL5 that pairs Quarterly Theory cycles anchored to New York time with a correlated-symbol SSMT divergence to time reversals. The article shows how to map cycles and quarters, detect the cross-symbol sweep disagreement, and derive the tCISD level whose break confirms the change in delivery. You will get a working entry logic that arms on divergence and executes on a confirmation close or a retest.
preview
Quick Integration of a Large Language Model into MetaTrader 5 (Part I): Building the Model

Quick Integration of a Large Language Model into MetaTrader 5 (Part I): Building the Model

The article explores the revolutionary integration of large language models (LLMs) with the MetaTrader 5 trading platform, where AI does not simply predict prices but makes autonomous trading decisions by analyzing market context much like an experienced trader. The author highlights a fundamental difference between LLMs and classical machine learning models such as CatBoost — the ability to engage in metacognition and self-reflection, which allows the system to learn from its own mistakes and improve its strategy.
preview
The Avellaneda-Stoikov Model: Inventory-Aware Quoting for Two-Sided Strategies

The Avellaneda-Stoikov Model: Inventory-Aware Quoting for Two-Sided Strategies

This article builds the Avellaneda–Stoikov formulas in MQL5, feeds them with rolling estimates of mid-price volatility and a proxy for order-flow intensity, and plots the reservation price with bid and ask in real time. A bar-by-bar simulation contrasts adaptive and fixed quoting under the same fill rules. The result is a tested class, an indicator, and a backtest to improve inventory control in two‑sided strategies.
preview
Price Action Analysis Toolkit Development (Part 77): Building a Searchable Indicator Panel for MetaTrader 5

Price Action Analysis Toolkit Development (Part 77): Building a Searchable Indicator Panel for MetaTrader 5

A modular indicator search system for MetaTrader 5 that replaces manual navigation through built-in indicator categories with a searchable interface. The application integrates an indicator catalog, search engine, chart launcher, and graphical panel, allowing indicators to be located, filtered, and attached to the appropriate chart window from a single interface.
preview
Neural Networks in Trading: An Intelligent Forecast Pipeline (Time-MoE)

Neural Networks in Trading: An Intelligent Forecast Pipeline (Time-MoE)

We invite you to explore the modern Time-MoE framework, which has been adapted for time series forecasting tasks. In this article, we will implement the key components of the architecture step by step, providing explanations and practical examples along the way. This approach will allow you not only to understand how the model works, but also to apply those principles to real-world trading scenarios.
preview
A Team of AI Agents with Profit-Based Rotation: The Evolution of a Living Trading System in MQL5

A Team of AI Agents with Profit-Based Rotation: The Evolution of a Living Trading System in MQL5

Financial management as an ecosystem: Seven AI traders with different personalities and strategies instead of a single algorithm. They compete for capital, learn from their mistakes, and make decisions collectively. The article explains the principles behind the Modern RL Trader system, in which the code possesses consciousness and emotions, creating a living, evolving trading mind.
preview
Neural Networks in Trading: A Cross-Domain Time Series Forecasting Framework (Conclusion)

Neural Networks in Trading: A Cross-Domain Time Series Forecasting Framework (Conclusion)

The article focuses on the practical implementation of the TimeFound model for time series forecasting. The key stages of implementing the framework's main approaches using MQL5 are examined.
preview
Path Signatures for Lead-Lag Detection

Path Signatures for Lead-Lag Detection

Build a level-2 path-signature engine in pure MQL5 to read the lead-lag ordering between two data streams without choosing a lag and without a linear model. The article delivers a reusable library, an indicator that plots the Levy‑area oscillator, and a simple rule‑based Expert Advisor. Code is cross‑checked against closed‑form cases, and the components are ready to plug into your projects.
preview
A Reinforcement Learning System for Algorithmic Trading in MQL5

A Reinforcement Learning System for Algorithmic Trading in MQL5

The article describes the development of a multi-agent machine learning system for algorithmic trading on MetaTrader 5 based on reinforcement learning. The system has a three-tier architecture: memory neurons store experience, agents make independent decisions, and the collective mind combines them through weighted voting. The system is continuously improved through Q-learning, pruning of ineffective neurons, and evolutionary reduction of exploration.
preview
Neural Networks in Trading: A Cross-Domain Time Series Forecasting Framework (TimeFound)

Neural Networks in Trading: A Cross-Domain Time Series Forecasting Framework (TimeFound)

In this article, we build the core of the TimeFound intelligent model step by step, adapting it to real-world time series forecasting tasks. If you are interested in the practical implementation of neural network patching algorithms in MQL5, you have come to the right place.
preview
Crystal Structure Algorithm (CryStAl)

Crystal Structure Algorithm (CryStAl)

This article presents two versions of the Crystal Structure Algorithm: the original and the modified version. The Crystal Structure Algorithm (CryStAl), published in 2021 and inspired by the physics of crystal structures, was positioned as a parameter-free metaheuristic for global optimization. However, testing revealed a critical problem with the algorithm. A modified version, CryStAlm, is also presented; it addresses the original's key shortcomings.
preview
Building a Divergence System (Part III): The Adaptive SuperTrend EA

Building a Divergence System (Part III): The Adaptive SuperTrend EA

The article implements a self-sufficient Adaptive SuperTrend EA with internal calculations on a selectable timeframe, avoiding external buffers and indicator files. It includes risk-based lot sizing, ATR stops, stepwise RR trailing, optional anti-repainting confirmation, and session control. Practitioners can reuse the structure for consistent new‑bar signal handling and broker‑compliant order validation.
preview
Streaming MetaTrader 5 Trade Events to a Local HTTP Server Using WinINet in MQL5

Streaming MetaTrader 5 Trade Events to a Local HTTP Server Using WinINet in MQL5

An MQL5 implementation sends trade lifecycle events to a local HTTP service through WinINet with a reusable session and per-request handles. The trade callback only enqueues JSON and returns, while a 500 ms timer drains the queue and retries failed posts, preserving order. A three-stage log policy keeps the Experts tab clear during downtime and summarizes recovery.
preview
Mathematical Models in Grid Strategies

Mathematical Models in Grid Strategies

In this article, we will examine the application of mathematics to grid strategies. We will consider the basic principles of the strategy, as well as its advantages and disadvantages. You will learn how to build a trading grid, set optimal parameters, and manage risks effectively.
preview
Building a Modular Fair Value Gap (FVG) Detection Engine in MQL5

Building a Modular Fair Value Gap (FVG) Detection Engine in MQL5

This article introduces a modular Fair Value Gap (FVG) detection engine for MQL5 packaged as a reusable include class, it evaluates imbalance zones on closed bars, applies a Simple True Range average filter to eliminate low-volatility noise, and supports wick-touch and close-through mitigation. A companion diagnostic indicator plots active gaps, and an Expert Advisor template demonstrates automated pullback entries with new-bar execution controls.
preview
Automating Trading Strategies in MQL5 (Part 51): The Bread and Butter Judas Swing Model with Premium and Discount

Automating Trading Strategies in MQL5 (Part 51): The Bread and Butter Judas Swing Model with Premium and Discount

We build a session-based reversal program in MQL5 using the Bread and Butter Judas Swing model. It derives a higher-timeframe daily bias, defines New York kill zones, maps each session's premium and discount from the live range, and requires a sweep before a market structure shift confirms entry. Readers get a ready approach to arm setups only during active sessions and execute in the bias direction with clear, testable rules.
preview
Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Final Part)

Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Final Part)

The Mantis framework transforms complex time series into informative tokens and serves as a reliable foundation for an intelligent trading agent capable of operating in real time.
preview
Artificial Coronary Circulation Algorithm (ACCS)

Artificial Coronary Circulation Algorithm (ACCS)

A metaheuristic algorithm that simulates the growth of coronary arteries in the human heart for optimization problems. It uses the principles of angiogenesis (the growth of new blood vessels), bifurcation (branching), and pruning of weak branches to find optimal solutions in a multidimensional space. Testing its effectiveness across a wide range of tasks yielded unexpected results.
preview
Hierarchical Risk Parity: A Robust Portfolio Allocator and Expert Advisor

Hierarchical Risk Parity: A Robust Portfolio Allocator and Expert Advisor

We implement a Hierarchical Risk Parity allocator in MQL5 as a single class, validate each stage against an independent Python reference, and package it in a rebalancing Expert Advisor. The pipeline covers returns, covariance/correlation, clustering, quasi-diagonalization, and recursive bisection, and contrasts HRP with Markowitz on stressed data. You finish with a verified allocator and an EA ready for basket-level testing.
preview
How to Detect and Normalize Chart Objects in MQL5 (Part 4): Fully Automated Analytical Objects System

How to Detect and Normalize Chart Objects in MQL5 (Part 4): Fully Automated Analytical Objects System

This part extends the series with a modular, event-driven MQL5 pipeline: swing detection feeds an object placer for trendlines, SR, Fibonacci, channels, and pitchforks; evaluators monitor interactions and generate signals; adaptive logic executes trades with valid stops per instrument. The topology manager synchronizes placement, scanning, and processing. The code is structured into reusable components for easy reuse and scaling.
preview
Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Building Objects)

Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Building Objects)

Mantis is a versatile tool for in-depth time series analysis that can be flexibly scaled to accommodate any financial scenario. Learn how a combination of patching, local convolutions, and cross-attention enables a highly accurate interpretation of market patterns.
preview
Real-Time Trade Event Logger to SQLite via MQL5 DLL Bridge

Real-Time Trade Event Logger to SQLite via MQL5 DLL Bridge

The article shows how to build an MQL5 EA that writes every deal to an SQLite database the moment it appears, using the built-in Database API as the SQLite bridge. It implements an event data model, a prepared INSERT workflow reused across calls, session-safe recovery after restarts, and deal detection via OnTrade(). You can open the resulting file with any SQLite client to run queries for analysis and reporting.
preview
Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Mantis)

Neural Networks in Trading: Effective Feature Extraction for Accurate Classification (Mantis)

Meet Mantis — a lightweight foundation model for time series classification based on a Transformer architecture, featuring contrastive pre-training and hybrid attention that deliver record-breaking accuracy and scalability.
preview
Neural Networks in Trading: Generalizing Time Series Without Data-Specific Dependence (Core Model Modules)

Neural Networks in Trading: Generalizing Time Series Without Data-Specific Dependence (Core Model Modules)

We continue our acquaintance with the Mamba4Cast framework. Today, we will delve into the practical implementation of the proposed approaches. Mamba4Cast was designed not for lengthy warm-up on every new time series, but for immediate deployment. Thanks to the concept of Zero-Shot Forecasting, the model can produce high-quality forecasts on real-world data without additional training or hyperparameter tuning.
preview
Building Your Personal Expert Advisor (Part 1): From Fragile Script to Working EA

Building Your Personal Expert Advisor (Part 1): From Fragile Script to Working EA

This article focuses on EA architecture rather than signal design. Starting with a flawed Moving Average crossover EA, we add new‑bar detection to prevent duplicate entries, Magic Number and position awareness, ATR‑based risk levels, and data and trade result validation, along with basic safeguards. You obtain a practical base to build and test advanced systems.
preview
Creating a Probabilistic Market-Neutral Trading Robot Based on a Return Distribution

Creating a Probabilistic Market-Neutral Trading Robot Based on a Return Distribution

A market-neutral trading strategy based on the empirical return distribution offers an alternative to traditional technical analysis methods, replacing price direction forecasting with the statistical placement of orders at levels the price is likely to reach. This article provides a detailed analysis of the mathematical framework for calculating percentiles, algorithms for weighting position sizes based on the probability of an order being triggered, and mechanisms for adapting to changing market conditions through grid expiration. A complete implementation in MQL5 is provided.
preview
Trading Options Without Options (Part 3): Complex Option Strategies

Trading Options Without Options (Part 3): Complex Option Strategies

The article discusses flat (non-directional) and trend-following (directional) option strategies and their implementation in MQL5. The EA described in the previous article is updated. The display of option levels has been added. Now it is time to examine the strategies used by options traders in practice and put them into action.
preview
Formulating Dynamic Multi-Pair EA (Part 10): Asymmetric Stop-Loss Logic Based on Pair-Specific Volatility Signatures

Formulating Dynamic Multi-Pair EA (Part 10): Asymmetric Stop-Loss Logic Based on Pair-Specific Volatility Signatures

The EA learns each symbol's volatility profile before trading by processing 1000 bars and summarizing candle ranges, bodies and wicks, noise ratio, trend runs, pullback size, and true‑range dispersion. A classifier assigns regime and structure labels per pair. The stop‑loss optimizer maps those labels to a symbol‑specific ATR multiplier, and the risk module sizes lots to maintain constant percentage risk.
preview
Price Action Analysis Toolkit Development (Part 76): One-Click Symbol Dashboard for Centralized Multi-Chart Management in MQL5

Price Action Analysis Toolkit Development (Part 76): One-Click Symbol Dashboard for Centralized Multi-Chart Management in MQL5

Learn to assemble an MT5 Expert Advisor that hosts a chart management dashboard written in MQL5. The guide walks through shared definitions, symbol acquisition and filtering, chart lifecycle functions, and a UI panel with search, scrolling, and state indicators, all driven by events and a timer. The result is a reproducible tool that reduces clicks and accelerates multi-symbol analysis.
preview
Automating Classic Market Methods in MQL5 (Part 5): The Original Turtle Trading Rules

Automating Classic Market Methods in MQL5 (Part 5): The Original Turtle Trading Rules

This article builds a complete MQL5 Expert Advisor that implements the original Turtle Trading rules from Curtis Faith. It covers both systems: 20/55-day breakouts, the System 1 skip rule, N (Wilder ATR) for volatility-adjusted sizing, a four‑unit pyramid with N/2 adds, a unified 2N stop, and 10/20-day exits. You will get compilable code, implementation details, and a backtesting procedure on EURUSD.
preview
Automating Classic Market Methods in MQL5 (Part 4): Mark Minervini's Trend Template

Automating Classic Market Methods in MQL5 (Part 4): Mark Minervini's Trend Template

This article presents TrendTemplateEA, an Expert Advisor implementing Mark Minervini's eight-condition trend template for daily forex charts. It evaluates all conditions on every bar and enters only when they are simultaneously satisfied, using RSI above 50 in place of the stock market RS rating. The entry trigger is a 20-bar high breakout on expanding volume, with all rules coded and testable in MQL5.
preview
Developing a Multi-Currency Expert Advisor (Part 29): Improving the Conveyor

Developing a Multi-Currency Expert Advisor (Part 29): Improving the Conveyor

We are going to improve the usability of the automated optimization conveyor: we will explore the process from creating an optimization project to testing the final EA. For clarity, let us walk through the entire process step by step creating the final EA, while stopping to make any desired corrections.
preview
Exporting MetaTrader 5 Open Positions to a Live-Refreshing HTML Dashboard

Exporting MetaTrader 5 Open Positions to a Live-Refreshing HTML Dashboard

The article builds an MQL5 Expert Advisor that writes a self-refreshing HTML positions dashboard to MQL5/Files on every tick, so you can monitor open trades in any browser. It covers reading live position data, generating a complete page with inline CSS and a JavaScript reload timer, and writing the file atomically. The design escapes HTML in comments, shows an explicit empty state, and writes a clear offline page on EA shutdown.
preview
Defining your Edge (Part 2): Using Divergence Mapping and a Temporal Fusion Transformer in a Trading Robot

Defining your Edge (Part 2): Using Divergence Mapping and a Temporal Fusion Transformer in a Trading Robot

In this article we make the case for merging Divergence Mapping with a Temporal Fusion Proxy in a Trading Robot. Rather than depending on lagging price confirmations, the Divergence Mapping's thesis is that acting like a structural sensor can help identify hidden momentum shifts from price action and indicator anomalies. To establish how these anomalies are interpreted over time we use a Temporal Fusion Transformer proxy. This network incorporates historical context to weigh developing trends such that merging it with Divergence Mapping should set us up to spot shifts in accumulation and distribution before price breakouts.
preview
Mapping the Shape of Price: The Mapper Lens and Cover in MQL5

Mapping the Shape of Price: The Mapper Lens and Cover in MQL5

The article introduces the Mapper pipeline in MQL5 by implementing the two fundamental components: CTDAMapperFilter (lens) and CTDAMapperCover (overlapping intervals). It explains three lens options—eccentricity, density, and coordinate—plus cover parameters (resolution and gain), and demonstrates how a price point cloud is reduced to one value per point and interval memberships. Readers obtain ready inputs for subsequent clustering and graph construction.