Articles on the MQL5 programming and use of trading robots

icon

Expert Advisors created for the MetaTrader platform perform a variety of functions implemented by their developers. Trading robots can track financial symbols 24 hours a day, copy deals, create and send reports, analyze news and even provide specific custom graphical interface.

The articles describe programming techniques, mathematical ideas for data processing, tips on creating and ordering of trading robots.

Add a new article
latest | best
preview
Developing a Reusable Dynamic Volatility Trailing Stop Engine in MQL5

Developing a Reusable Dynamic Volatility Trailing Stop Engine in MQL5

This article presents a modular, object-oriented volatility trailing stop engine for MQL5 packaged as a reusable include class, it calculates dynamic stop-loss levels using a True Range average filter on closed bars, supports step-based trailing, includes a visual diagnostic indicator, and provides an Expert Advisor execution template.
preview
Defining your Edge (Part 6): Harnessing Fourier Transform and a Spiking Neural Network in an Expert Advisor

Defining your Edge (Part 6): Harnessing Fourier Transform and a Spiking Neural Network in an Expert Advisor

Article revisits Trading Robot that merged Discrete Fourier Transform with Leaky Integrate-and-Fire Spiking Neural Network. Evaluation is made over the seven operating modes with different symbols, timeframes, and test windows. We use two-thirds of the test window to optimize while the one-third does a forward walk run. This study tries to detail parameter interactions, input scaling, gating effects, and outlines practical checks that include rolling windows, frozen inputs, and others. The goal remains identifying settings worth further testing or paper trading.
preview
Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (Conclusion)

Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (Conclusion)

The article describes a practical implementation of the HimNet framework based on MQL5, ready for integration into automated trading. We demonstrate how heterogeneity-adapted meta-parameters transform the model into a universal tool capable of handling fluctuating volatility.
preview
Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (Key Components)

Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (Key Components)

In this article, we take a detailed look at the algorithms used to implement the key components of the HimNet framework. We demonstrate how, with a minimal number of trainable components, a high degree of consistency and controllability can be achieved throughout the entire system. The presented implementation is compact and transparent, which makes it easier to adapt to real-world market tasks.
preview
Automating Classic Market Methods in MQL5 (Part 8): Ed Seykota's Trend Following System

Automating Classic Market Methods in MQL5 (Part 8): Ed Seykota's Trend Following System

The article presents a full MQL5 implementation of a multi-symbol trend system: dual EMA crossovers for entries, ADX to avoid ranges, ATR to normalize position size, and a heat monitor to cap total portfolio risk. We explain the architecture, calculation details, and entry/exit logic on daily bars. The result is a practical EA template for systematic, risk-aware portfolio trading.
preview
Developing a Multi-Currency Expert Advisor (Part 31): Secrets of the Optimization Project Creation Step (I)

Developing a Multi-Currency Expert Advisor (Part 31): Secrets of the Optimization Project Creation Step (I)

The article examines two practical aspects of the Adwizard-based optimization pipeline: diagnostics and recovery after failures when generating the final Expert Advisor database, as well as preliminary selection of strategy parameter ranges before project creation. It is shown how analyzing the stages/jobs/tasks tables in SQLite and restarting stages based on their statuses help restore the process, while trial optimization narrows the search space, eliminates redundant parameters, and reduces the risk of getting stuck at local maxima.
preview
Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (HimNet)

Neural Networks in Trading: Heterogeneity-Informed Meta-Parameter Learning (HimNet)

We invite you to explore the HimNet framework, which combines the flexibility of spatio-temporal adaptation with high computational efficiency, enabling accurate and stable forecasts for financial time series. The article explains in detail how its key components interact with one another, transforming complex algorithms into a manageable architecture.
preview
Automating Classic Market Methods in MQL5 (Part 7): The Nicolas Darvas Box System

Automating Classic Market Methods in MQL5 (Part 7): The Nicolas Darvas Box System

This article implements the Darvas Box method as a complete MQL5 Expert Advisor. We code box detection with a three-session hold, volume contraction during consolidation, and volume-confirmed breakouts, plus a staircase pyramid with a shared, rolling stop at the latest box floor. The EA uses a state machine to run box scanning and trade management in parallel, providing a ready-to-compile system with configurable inputs and clear on-chart diagnostics.
preview
Defining your Edge (Part 5): Using GARCH Variance and Volatility-Scaled LSTM in an Expert Advisor

Defining your Edge (Part 5): Using GARCH Variance and Volatility-Scaled LSTM in an Expert Advisor

We merge GARCH(1,1) variance projections with ATR plus Bollinger-Bands patterns to form an algorithm that could optionally be used with volatility-scaled LSTM within LSTM Wizard-ready signal class. We cover feature scaling, mode scoring, thresholds, and safety checks. Readers can replicate backtest/forward test results to verify if the recurrent layer gives incremental discrimination over our deterministic baseline.
preview
Neural Networks in Trading: The Temporal Query Model (Conclusion)

Neural Networks in Trading: The Temporal Query Model (Conclusion)

We are pleased to present the final stage of the TQNet framework’s development and testing, where theory meets real-world trading practice. We will move from historical training to a stress test using recent market data, evaluating the model's robustness and accuracy. The final results are not just dry statistics, but also a clear demonstration of the practical value of the proposed approach.
preview
Neural Networks in Trading: The Temporal Query Model (TQNet)

Neural Networks in Trading: The Temporal Query Model (TQNet)

The TQNet framework opens up new possibilities for modeling and forecasting financial time series by combining modularity, flexibility, and high performance. The article explores the possibility of implementing complex mechanisms for handling global correlations, including advanced parameter initialization methods.
preview
Developing a Multi-Currency Expert Advisor (Part 30): From Trading Strategy to Launching a Multi-Currency Expert Advisor

Developing a Multi-Currency Expert Advisor (Part 30): From Trading Strategy to Launching a Multi-Currency Expert Advisor

The article outlines the complete process of creating a multi-currency Expert Advisor using the Adwizard library for MetaTrader 5: from setting up the environment for creating optimization projects to obtaining the final multi-currency Expert Advisors, which combine multiple instances of a simple trading strategy. We will walk through setting up the necessary input parameters, conventions for convenient file names, and launching three instances of the final Expert Advisors on different trading accounts with different parameters.
preview
Building Your Personal Expert Advisor (Part 6): Risk Management V — Portfolio and Correlated Risk

Building Your Personal Expert Advisor (Part 6): Risk Management V — Portfolio and Correlated Risk

This part implements PortfolioRisk.mqh, a shared library that shifts risk management to the account level. It scans positions and pending orders, computes margin and floating results, counts symbols, and decomposes pairs into currencies to detect concentration, then validates each new trade against portfolio limits. The Series EA example illustrates configuring scope (account-wide or magic-filtered), registering magics, and integrating the pre-trade gate.
preview
Defining your Edge (Part 4): Applying Isotonic Regression and PNN Price-Forecasting in an Expert Advisor

Defining your Edge (Part 4): Applying Isotonic Regression and PNN Price-Forecasting in an Expert Advisor

We consider the methods with which Isotonic Regression calibrates raw RSI, Stochastic and price-action signal scores into probabilities that are sorted, while a separate Probability based Neural Network evaluates similar historical market states. This article uses both approaches in a ready-made MQL5 custom signal class that is compatible with MQL5 Wizard and provides up to 7 selectable entry modes. Reproducible tests compare isotonic-only signals with the combined Isotonic-PNN model to assess whether the network adds useful information beyond the simpler baseline.
preview
Honest Backtesting of Swing Strategies on Index CFDs: Financing Costs, Swap Modes, and What the Strategy Tester Cannot Model

Honest Backtesting of Swing Strategies on Index CFDs: Financing Costs, Swap Modes, and What the Strategy Tester Cannot Model

Financing drives multi‑day index‑CFD results: in one full‑history test, swap consumed 44% of gross profit and all profit on one symbol. We convert swaps to annualized rates, contrast four brokers and two financing models with a read‑only script, and quantify a Strategy Tester issue where a single current swap is used for all history, inflating implied rates by up to seven times. The piece provides a repeatable cost‑audit method.
preview
Neural Networks in Trading: Decomposition Instead of Scaling (Conclusion)

Neural Networks in Trading: Decomposition Instead of Scaling (Conclusion)

We invite you to learn about an algorithm for decomposing a time series into meaningful layers and using them to build a parsimonious model. We systematically present the architecture, the practical implementation in MQL5/OpenCL, and real-world tests using historical market data.
preview
Neural Networks in Trading: Decomposition Instead of Scaling — Building Modules

Neural Networks in Trading: Decomposition Instead of Scaling — Building Modules

In this article, we continue our hands-on exploration of SSCNN — a next-generation architectural solution capable of processing fragmented time series. Instead of blind scaling — smart modularity, attention to detail, and targeted normalization. Step by step, we are creating computational blocks in the MQL5 environment and laying the foundation for reliable predictive analysis.
preview
Building Your Personal Expert Advisor (Part 4): Risk Management III—Risk Models and Order Execution

Building Your Personal Expert Advisor (Part 4): Risk Management III—Risk Models and Order Execution

The EA now defines risk by percentage, fixed cash, or fixed lot and can measure percentage against balance or equity. It supports market, limit, and stop orders, sizes from the planned entry, and enforces spread‑aware stop minima. Additional safeguards include downward volume rounding, explicit handling when the minimum lot exceeds target risk, and pending‑order distance/expiry checks, organized under a Plan–Validate–Execute structure.
preview
Automating Classic Market Methods in MQL5 (Part 6): Jesse Livermore's Pivotal Point System

Automating Classic Market Methods in MQL5 (Part 6): Jesse Livermore's Pivotal Point System

This article presents a complete MQL5 Expert Advisor that implements Jesse Livermore's market key as a deterministic state machine. It detects pivotal levels from consolidations using ATR and volume expansion, scales in across four tranches, and exits on abnormal behavior defined by range and volume. The EA validates inputs in OnInit, requires a hedging account, and compiles out of the box for testing Livermore's rules on daily data.
preview
MQL5 Bootstrap (IV): Trailing and Break-even Stop Helpers

MQL5 Bootstrap (IV): Trailing and Break-even Stop Helpers

This article presents reusable MQL5 utilities for managing trailing and break-even stops. It covers fixed-point, moving average, ATR, Parabolic SAR, money-based, and time-periodic trailing, plus break-even by points and by money, with activation thresholds, step logic, reverse-move protection, and broker-level validation. Code examples and Bootstrap classes show how to integrate these helpers into Expert Advisors to standardize position control and reduce duplicate code.
preview
Neural Networks in Trading: Generalizing Time Series Without Data-Specific Dependence (Conclusion)

Neural Networks in Trading: Generalizing Time Series Without Data-Specific Dependence (Conclusion)

The article will show you how Mamba4Cast turns theory into a working trading algorithm and lays the groundwork for your own experiments. Do not miss this opportunity to gain a full range of knowledge and inspiration for developing your own strategy.
preview
Building Your Personal Expert Advisor (Part 5): Risk Management IV—Basket Risk and Strategy-Specific Sizing

Building Your Personal Expert Advisor (Part 5): Risk Management IV—Basket Risk and Strategy-Specific Sizing

Part 5 moves risk control from single trades to a basket-level framework. The EA aggregates its own positions, computes volume‑weighted entry, floating P/L including swap, and used margin, then enforces limits on combined loss, margin, position count, and time underwater, while logging maximum adverse excursion. A companion mean‑reversion EA demonstrates target‑based sizing and caps on implied risk that remains hidden when trades are evaluated in isolation.
preview
Automating Chart Patterns in MQL5 (Part 2): The Double Top and Double Bottom

Automating Chart Patterns in MQL5 (Part 2): The Double Top and Double Bottom

We build a robust MQL5 detector for double tops and double bottoms that first confirms the H4 trend, then validates six conditions (point equality, neckline placement, ordering, width, height, and ATR‑based tolerances). The neckline break is timed on the chart's timeframe, and a three-state machine ensures each pattern trades once. The measured‑move target translates structure into clear exits.
preview
Neural Networks in Trading: Decomposition Instead of Scaling (SSCNN)

Neural Networks in Trading: Decomposition Instead of Scaling (SSCNN)

In this article, we begin our exploration of the SSCNN framework — a modern architectural solution for time series analysis that combines accuracy, a structured design, and high computational efficiency. We will systematically examine its theoretical aspects, highlight the key differences from its predecessors, and begin the practical implementation of its basic components in the MQL5 environment.
preview
Defining your Edge (Part 3): Using HMM and GRU in an Expert Advisor

Defining your Edge (Part 3): Using HMM and GRU in an Expert Advisor

We examine how a Hidden Markov Model (HMM) estimates latent market regimes while basing on observable price and indicator sequences. This is done by estimating the probability of state transitions. A Gated Recurrent Unit (GRU) network models time dependencies and keeps important information over several observations. In an Expert Advisor, HMM-based regime probabilities, can be merged with GRU-based sequence learning to better classify increments in accumulation, distribution, and momentum prior to their showing up in regular price confirmations.
preview
Partial Information Decomposition: When Two Indicators Together Say More Than Either Alone

Partial Information Decomposition: When Two Indicators Together Say More Than Either Alone

We introduce a Partial Information Decomposition library for MQL5 that decomposes two sources about a target into four atoms: unique to each, shared, and synergy. The implementation uses quantile binning, tabulated logarithms, and a maximum-entropy fit (for I_ccs), and it pairs results with a block-permutation null because atoms sit above zero on finite samples. Use it to screen indicator pairs and judge significance, including family-wise correction.
preview
Neural Networks in Trading: Disentangling Structured Components (Conclusion)

Neural Networks in Trading: Disentangling Structured Components (Conclusion)

The article provides a detailed explanation of the SCNN architecture and one way to implement it using MQL5. We will show how time series decomposition can be combined with neural network methods and attention mechanisms.
preview
Building Your Personal Expert Advisor (Part 2): Risk Management and Dynamic Lot Sizing

Building Your Personal Expert Advisor (Part 2): Risk Management and Dynamic Lot Sizing

This part implements risk-based position sizing for the EA. Lot size is derived from account balance, a chosen risk percent, and ATR-based stop distance, then confined and rounded to the broker's volume rules and minimum stop levels. An optional drawdown-aware layer reduces risk during equity declines. Readers get a reproducible sizing function that keeps per-trade risk consistent and orders acceptable to the server.
preview
Neural Networks in Trading: Disentangling Structured Components (Encoder)

Neural Networks in Trading: Disentangling Structured Components (Encoder)

We invite you to explore the next stage in implementing the SCNN framework, which combines flexibility and interpretability, allowing structural components of a time series to be identified precisely. The article provides a detailed explanation of the mechanisms of adaptive normalization and attention, which ensure the model's resilience to changing market conditions.
preview
First Fractal Breakout — Intraday Strategy, Expert Advisor and Backtesting

First Fractal Breakout — Intraday Strategy, Expert Advisor and Backtesting

This article develops a market‑structure‑driven intraday breakout system based on Bill Williams fractals. We define session bounds, derive volatility‑scaled stops, use fixed risk and take‑profit multipliers, and limit trades to one per direction. An MQL5 Expert Advisor, visualization and statistics, tick-level backtests, an ORB comparison, and a cross-asset forward test provide a complete, replicable workflow.
preview
Neural Networks in Trading: Disentangling Structured Components (SCNN)

Neural Networks in Trading: Disentangling Structured Components (SCNN)

We invite you to explore the innovative SCNN framework, which takes time series analysis to a new level by clearly separating data into long-term, seasonal, short-term, and residual components. This approach significantly improves forecasting accuracy by allowing the model to adapt to complex and changing market dynamics.
preview
Reinforcement Learning Meets MetaTrader 5: A Complete Pipeline for Training, Validating and Honestly Evaluating a Gold Trading Bot

Reinforcement Learning Meets MetaTrader 5: A Complete Pipeline for Training, Validating and Honestly Evaluating a Gold Trading Bot

This article presents a complete RL trading pipeline for XAUUSD: a supervised signal baseline with triple-barrier labels, PPO training, purged walk-forward validation with embargo, multi-seed checks, and contract-guarded deployment with normalization. It includes runnable code for data validation, features, environment, training, and broker‑based reconciliation. The live demo over 763 closed trades showed no statistically significant edge, and the methods highlight where information and costs, not architecture, set performance limits.
preview
Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (Conclusion)

Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (Conclusion)

We are pleased to present the final part of our series on GinAR — a neural network framework for time series forecasting. In this article, we analyze the results of testing the model on new data and assess its robustness under real-market conditions.
preview
Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (Key Components)

Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (Key Components)

We invite you to explore a new implementation of the key components of the GinAR framework — an adaptive algorithm for working with graph-structured time series. This article provides a step-by-step breakdown of the architecture and the algorithms for the forward pass and error backpropagation.
preview
Building a Visual Position Planning Tool for MetaTrader 5

Building a Visual Position Planning Tool for MetaTrader 5

This article develops a visual position planning tool in MQL5 for evaluating trade setups before execution. The tool utilizes interactive Entry, Stop-Loss, and Take-Profit lines to calculate the stop distance, risk amount, estimated position size, potential reward, and risk-to-reward ratio directly on the chart. It supports market, limit, and stop order scenarios while keeping the focus strictly on planning and analysis rather than trade execution.
preview
Building a Position Lifecycle Manager in MQL5 (Part 1): The Foundation of Reusable Position Management

Building a Position Lifecycle Manager in MQL5 (Part 1): The Foundation of Reusable Position Management

A state-driven Position Lifecycle Manager brings structure to post-entry trade handling in MetaTrader 5. It discovers open positions, tracks them via managed objects, applies ATR-based protection, executes break-even transitions, and removes completed trades, with a clear NEW → PROTECTED → BREAKEVEN → CLOSED flow. The article shows integration with the standard MACD EA to enable reuse across strategies.
preview
Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (GinAR)

Neural Networks in Trading: An End-to-End Multivariate Time Series Forecasting Model (GinAR)

We invite you to explore an innovative approach to forecasting time series with missing data using the GinAR framework. The article demonstrates the implementation of key components using OpenCL, which ensures high performance. In our next publication, we will take a detailed look at how to integrate these solutions into MQL5. This will help understand how to apply the method in practice in trading.
preview
Network Momentum for MetaTrader5: Trading the Lead-Lag Graph Between Markets

Network Momentum for MetaTrader5: Trading the Lead-Lag Graph Between Markets

This article builds a trend-following Expert Advisor that trades momentum spillover across markets, implemented fully in MQL5 without external solvers. It detects leaders with Derivative Dynamic Time Warping, learns a sparse weighted network by convex optimization, and propagates momentum through it with a reverting response. Readers get a step-by-step, reproducible pipeline and a working EA ready to run in the Strategy Tester.
preview
Motifs and Discords: Building a Matrix Profile from Scratch

Motifs and Discords: Building a Matrix Profile from Scratch

We build the Matrix Profile for MQL5 from the ground up and keep it numerically stable on real prices. The library includes rolling statistics, a radix-2 FFT powering MASS, and a STOMP self-join, with results matched to stumpy. A compact facade, an indicator that draws the profile and flags discords, and a demonstration Expert Advisor show how to read and use the signal in practice.
preview
Neural Networks in Trading: Probabilistic Time Series Forecasting (Conclusion)

Neural Networks in Trading: Probabilistic Time Series Forecasting (Conclusion)

We invite you to learn about the K²VAE framework and how the proposed approaches can be integrated into a trading system. You will learn how the hybrid Koopman–Kalman–VAE approach helps build adaptive and interpretable models. The article concludes with practical results from using the implemented solutions.