Articles on manual and algorithmic trading in MetaTrader 5

icon

This category features articles on all aspects of trading - from manual to fully automatic trading, from Expert Advisor ideas to trading robot creation using the MQL5 Wizard. Position management, processing of trade events and money management - these integral parts of trading are covered in theses articles.

Learn how to copy trading signals and how to provide around-the-clock operation of Expert Advisors, how to create a trading robot and how to run MetaTrader on Linux and MacOS, what social trading is and how to order a trading robot.

Add a new article
latest | best
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
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
Porting the Canonical Catch22 Time-Series Feature Set and Testing It on Volatility Regimes

Porting the Canonical Catch22 Time-Series Feature Set and Testing It on Volatility Regimes

We present a native MQL5 implementation of the catch22 feature set: all 22 canonical time-series characteristics in a reusable class validated against pycatch22. Using a leak-free pipeline (chronological split, purging, embargo), we run a three-arm ablation—classic indicators, catch22, and combined—for volatility-regime classification. Finally, we deploy the combined model as a Strategy Tester regime filter to quantify its impact on a simple baseline strategy.
preview
From One Price to Four: Range-Based Volatility Estimators for MetaTrader 5

From One Price to Four: Range-Based Volatility Estimators for MetaTrader 5

Close-to-close volatility ignores the high, the low, and overnight gaps. We build a reusable MQL5 library implementing four range-based estimators from Parkinson to the gap-robust Yang-Zhang, and put it to work in a comparison indicator and a set of adaptive volatility bands.
preview
Developing a Terminal Manager (Part 2): Running Multiple Terminal Instances

Developing a Terminal Manager (Part 2): Running Multiple Terminal Instances

Let's move on to using multiple terminal instances on the server by setting up a simple control panel for starting and stopping them. Now it is time to expand the functionality and move on to the next stages — implementing more complex features, such as managing multiple terminal instances, state persistence, integration with the MetaTrader 5 API, and a web interface with comprehensive information about the terminals.
preview
Developing a Terminal Manager (Part 1): Problem Statement

Developing a Terminal Manager (Part 1): Problem Statement

How can we conveniently monitor multiple terminals running Expert Advisors, especially when they are on different computers? Let's try to create a web interface for managing the launch of MetaTrader 5 trading terminals and viewing detailed information about the operation of each instance.
preview
The Blue Monkey (BM) Algorithm

The Blue Monkey (BM) Algorithm

The article presents an implementation of the Blue Monkey metaheuristic algorithm, which is based on a model of the social behavior of blue monkeys. The article examines the key mechanisms of the algorithm — the group structure of the population, following local leaders, and generational renewal through the replacement of the worst adults with the best offspring — and analyzes the test results.
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
Crow Search Algorithm (CSA)

Crow Search Algorithm (CSA)

The Crow Search Algorithm (CSA) is an elegant metaheuristic inspired by crows’ ability to hide food and find other crows' caches, solving optimization problems by balancing following successful solutions with random exploration of the search space. Let's find out how well the algorithm performs.
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
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
Where should your stop-loss really sit? An MAE/MFE excursion analyzer in MQL5

Where should your stop-loss really sit? An MAE/MFE excursion analyzer in MQL5

Stop-loss and take-profit placement is usually the least-measured decision in a trading system. This Expert Advisor reads your closed history, replays M1 price between each entry and exit to measure Maximum Adverse and Favorable Excursion per trade, and splits winners from losers. From the distributions and trade efficiency it derives data-driven stop and target levels - measured from your own account, not a rule of thumb. Analysis only; it does not trade.
preview
Bison Algorithm (BIA)

Bison Algorithm (BIA)

A new optimization method, the Bison Algorithm (BIA), uses two strategies, inspired by the behavior of bison, for solving continuous problems with a single objective function. The key features of BIA are two fundamental principles borrowed from the behavior of bison: the ability to move dynamically and a defensive strategy.
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
Ordinal Pattern Transition Networks in MQL5

Ordinal Pattern Transition Networks in MQL5

We implement ordinal pattern transition networks in MQL5: a Lehmer-code encoder, a directed network over ordinal price patterns, and three complexity metrics. Two indicators expose a trend-versus-range regime from time-irreversibility and an efficiency gauge from permutation entropy, with a transparent parameter sweep showing how to tune settings on FX data.
preview
Building a Correlation-Aware Portfolio Risk Monitor in MQL5

Building a Correlation-Aware Portfolio Risk Monitor in MQL5

The article quantifies correlation and portfolio risk in MetaTrader 5: from time-aligned returns to a covariance matrix, true portfolio variance against the independent-sum assumption, and position-level risk attribution. A MetaTrader 5 service runs in the background, shows the metrics on a small chart panel, and pushes alerts when risk thresholds are crossed. Source code is provided for an example script, a reusable risk engine class, and the service.
preview
Digital Signal Processing for Traders (Part 2): The Dominant Cycle, MAMA, and a Regime-Switching Expert Advisor

Digital Signal Processing for Traders (Part 2): The Dominant Cycle, MAMA, and a Regime-Switching Expert Advisor

In Part 2 we measure the market's dominant cycle using Ehlers' Hilbert-transform homodyne discriminator and wrap it as an indicator. We then build the MESA Adaptive Moving Average (MAMA) and its follower FAMA from that phase information. Finally, we combine MAMA/FAMA with the Even Better Sinewave to form a regime-switching Expert Advisor and test it on EURUSD in the Strategy Tester, giving you a complete, reproducible MQL5 implementation.
preview
Multi-Threaded Trading Robot with Machine Learning: From Concept to Implementation

Multi-Threaded Trading Robot with Machine Learning: From Concept to Implementation

The article presents a step-by-step development of a multi-threaded trading robot with machine learning in Python and MetaTrader 5. The system architecture is considered – from data collection and creation of technical indicators to training XGBoost models with portfolio risk management. The implementation of data augmentation, feature clustering via Gaussian Mixture Models, and flow coordination for parallel trading of multiple currency pairs is described in detail.
preview
Dingo Optimization Algorithm (DOA)

Dingo Optimization Algorithm (DOA)

The article presents a new metaheuristic method based on the hunting strategies of Australian dingoes: group attack, chase, and scavenging. Let's see how the Dingo Optimization Algorithm (DOA) performs algorithmically.
preview
From Option Chain to 3D Volatility Surface in MetaTrader 5

From Option Chain to 3D Volatility Surface in MetaTrader 5

This article walks through creating an MT5 indicator that ingests option chains from native symbols or CSV, inverts prices to implied volatility via a hybrid Newton–Raphson/bisection method, and assembles a clean strike–expiry grid. It then renders a shaded, rotatable 3D surface with the platform's DirectX layer, enabling clear, in-terminal analysis of skew and term structure using live or file-based data.
preview
Persistence Entropy as a Market Regime Indicator in MQL5

Persistence Entropy as a Market Regime Indicator in MQL5

This article turns the verified TDA pipeline into a live MQL5 indicator. It reduces each price window to two persistence-entropy lines (H0 and H1), computes a normalized loop-strength metric with an adaptive percentile band, and places fade marks only when loop strength is high and price hits a window extreme. You can attach the indicator, read six buffers from an Expert Advisor, and tune key window, ranking, and performance parameters.
preview
Analyzing the Hourly Movement of Trading Symbols and Their Spreads in MetaTrader 5

Analyzing the Hourly Movement of Trading Symbols and Their Spreads in MetaTrader 5

The ProSpread seasonality index indicator with a Moving Average is a technical analysis tool that identifies seasonal patterns in price movements, analyzes price behavior during specific trading hours and is able to work with either a single instrument or a spread between two assets. It also visualizes the statistical probability of directional movements.
preview
Building a Divergence System (Part II): Adaptive SuperTrend Custom Indicator

Building a Divergence System (Part II): Adaptive SuperTrend Custom Indicator

The article upgrades SuperTrend by integrating a divergence engine (MPO4 or RSI) the dynamically reduces the ATR multiplier during weakening momentum. It covers the shrinking formula, non-repainting state propagation with dedicated buffers, and a step-by-step MQL5 implementation on the price chart. You will learn how to interpret arrows and line flips, adjust inputs, and apply the indicator for disciplined trailing and earlier confirmations.
preview
Automating Trading Strategies in MQL5 (Part 50): Turtle Soup Liquidity Sweeps

Automating Trading Strategies in MQL5 (Part 50): Turtle Soup Liquidity Sweeps

We build an automated MQL5 program that trades Turtle Soup by fading false breakouts of the N-bar high and low. The article implements liquidity-sweep detection, confirmation closes back inside the level, sweep-depth and extreme-age filters, and an optional reversal-candle body check. It adds configurable dynamic or static stops, two take-profit modes, points-based trailing, and clear chart visuals, providing a ready baseline for backtesting and further customization.
preview
MQL5 Bootstrap (II): Essential Validators for Robust Trading Systems

MQL5 Bootstrap (II): Essential Validators for Robust Trading Systems

The article builds a reusable validation layer for Expert Advisors in MQL5. It implements lot-size rules and normalization, SL/TP and freeze-level guards, price digit normalization, margin sufficiency checks, unchanged-level filtering on modifications, account order-limit control, new-bar detection, symbol tradability checks, economic-calendar news windows, and session detectors. The result is cleaner code and fewer terminal errors in live trading.
preview
Persistent Homology in MQL5: The Reduction Algorithm and the Persistence Diagram

Persistent Homology in MQL5: The Reduction Algorithm and the Persistence Diagram

We complete persistent homology for MQL5 by reducing the Vietoris–Rips boundary matrix to a persistence diagram. The article implements Z/2 column reduction (CTDAReduction), a diagram container with analytics (CTDADiagram), and a facade that runs the six-stage pipeline in one call (CTDA). Outputs are cross-checked against Ripser to numerical agreement, enabling reliable diagram-based metrics.
preview
Automating Classic Market Methods in MQL5 (Part 3): Stan Weinstein Stage Analysis

Automating Classic Market Methods in MQL5 (Part 3): Stan Weinstein Stage Analysis

This article presents a complete Expert Advisor built around Stan Weinstein's Stage Analysis method. The EA classifies the market into one of four stages using the 30-week moving average slope and position and volume behavior, then trades only Stage 2 breakouts long and Stage 4 breakdowns short. It explains each stage, how to detect it programmatically, and why the method's discipline—trading only in the correct stage—is what produces the edge.
preview
Dream Optimization Algorithm (DOA)

Dream Optimization Algorithm (DOA)

A population-based optimization algorithm inspired by a controversial and little-studied phenomenon - the mechanism of human dreams. Agent groups with different "memory", cosine-wave modulation of motion, and an unusual 99/1 phase distribution — learn how these features affect the optimization efficiency of your trading strategies.
preview
Duelist Algorithm

Duelist Algorithm

What if your trading strategies could learn from each other, like real fighters? Duelist Algorithm is a new optimization method where trading system parameters literally duel for the right to be called the best.
preview
Automating Trading Strategies in MQL5 (Part 49): The Quasimodo (QM) Reversal Pattern

Automating Trading Strategies in MQL5 (Part 49): The Quasimodo (QM) Reversal Pattern

In this article, we build an automated trading program in MQL5 that detects the Quasimodo reversal pattern from a zig-zag of confirmed swing pivots. We work through swing detection, pattern arming, retrace entries at the QM line, and structural stop placement with risk-based sizing. We also add trade management with breakeven, trailing, and partial closing to handle open positions.
preview
The MQL5 Standard Library Explorer (Part 13): Implementing the Math Solvers Library in Trading

The MQL5 Standard Library Explorer (Part 13): Implementing the Math Solvers Library in Trading

We present a complete workflow for adaptive filtering in MQL5 using the CNlEq Levenberg–Marquardt–like solver. The EA fits a VAMAC model—two EWMAs with an ATR‑based scaling—by supplying residuals and a Jacobian through CNlEq's reverse‑communication loop, with optional numerical or analytical derivatives. Code, setup instructions, and GBPUSD H1 tests show how to replace static thresholds with on‑bar re‑estimation.
preview
From Cloud to Complex: The Vietoris-Rips Filtration in MQL5

From Cloud to Complex: The Vietoris-Rips Filtration in MQL5

We turn a price-embedded point cloud into a Vietoris–Rips filtration and its boundary matrix. The article enumerates vertices, edges, and triangles with filtration values, sorts them in entry order, and builds O(1) vertex/edge lookups. You get MQL5 classes CTDARips and CTDABoundary and a sparse Z/2 boundary suitable for the next-step persistence reduction.
preview
Community of Scientists Optimization (CoSO): Practice

Community of Scientists Optimization (CoSO): Practice

We resume the topic of optimization by the scientific community. CoSO should not be viewed as a ready-made solution, but as a promising research platform. With proper development, CoSO can find its niche in tasks where adaptability and resilience to change are important, and computation time is not critical.
preview
How to Detect and Normalize Chart Objects in MQL5 (Part 3): Alerting and Automated Trading from Manually Drawn Objects

How to Detect and Normalize Chart Objects in MQL5 (Part 3): Alerting and Automated Trading from Manually Drawn Objects

This article extends the chart‑object detector into a modular monitoring and execution layer. It defines objective interaction rules (touch, cross, breakout) for trendlines, Fibonacci levels, channels, rectangles, and pitchforks, then routes events through an interaction detector, alert manager, and optional trade executor. Orders use object geometry for stop‑loss and take‑profit. The result is a reproducible pipeline that converts static drawings into actionable alerts and, if enabled, trades.
preview
AI Trading Platform: Why MetaTrader 5 Is the Best Choice for Algorithmic Trading with Python, ONNX, and AI Assistant

AI Trading Platform: Why MetaTrader 5 Is the Best Choice for Algorithmic Trading with Python, ONNX, and AI Assistant

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.
preview
Trading Options Without Options (Part 2): Use in Real Trading

Trading Options Without Options (Part 2): Use in Real Trading

The article considers simple options strategies and their implementation in MQL5. We will develop a basic EA that will be modernized and become more complex.
preview
Building a Divergence System: Creating the MPO4 Custom Indicator

Building a Divergence System: Creating the MPO4 Custom Indicator

We introduce MPO4, a pressure-based oscillator that emphasizes the body and direction of candles in the context of current volatility. The article details its mathematics, normalization into a bounded range, and the EMA smoothing, then builds a pivot-driven divergence module designed not to repaint. You get complete MQL5 implementation and practical guidance for interpreting signals, including a comparison with RSI as an alternative source.