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
The MQL5 Standard Library Explorer (Part 17): Building a Reusable Portfolio Manager with CArrayObj

The MQL5 Standard Library Explorer (Part 17): Building a Reusable Portfolio Manager with CArrayObj

We present a multi‑symbol EA structure that moves symbol‑specific state into independently initialized CStrategyNode objects and manages them with CPortfolioManager. Using CArrayObj with FreeMode, Add(), At(), Delete(), Total(), and Clear(), the manager ensures safe ownership and isolation, while timer‑driven routing and completed‑bar gates keep processing deterministic. This lets you scale portfolios, control risk per node, and avoid duplicated event handling.
preview
Neural Networks in Trading: A Spiking Architecture for Spatio-Temporal Market Analysis (Conclusion)

Neural Networks in Trading: A Spiking Architecture for Spatio-Temporal Market Analysis (Conclusion)

The SDformerFlow framework transforms complex events in financial time series into structured representations, enabling the model to identify local fluctuations and global trends simultaneously. The multi-level U-structure ensures consistency between the forward pass and the backward pass, synchronization of gradients, and computational stability. Ultimately, SDformerFlow proves to be a powerful and flexible tool for building modern trading systems.
preview
Neural Networks in Trading: A Spatio-Temporal State Space Model for Financial Data Analysis (STSSM Block)

Neural Networks in Trading: A Spatio-Temporal State Space Model for Financial Data Analysis (STSSM Block)

The article explains the internal mechanics of the STSSM block and demonstrates how modern SSM approaches can be adapted to the event-driven logic of spiking models while maintaining high speed and expressive representations. Step by step, we work our way through the architecture, transforming the rigorous theory behind the authors' approach into a practical financial instrument for analyzing financial time series.
preview
Measuring What Matters (Part 5): The Risk Concentration Indicator — Plotting Eigenvalue Dominance Live

Measuring What Matters (Part 5): The Risk Concentration Indicator — Plotting Eigenvalue Dominance Live

This article presents a live MQL5 indicator for monitoring portfolio risk concentration through eigenvalue decomposition. The indicator calculates rolling covariance statistics for three instruments using persistent prefix sums, aligns price data by timestamp, handles missing observations, and plots the dominant eigenvalue as a percentage of total portfolio variance. The implementation provides a practical way to observe changes in portfolio risk concentration as the covariance structure evolves over time.
preview
Neural Networks in Trading: A Spiking Architecture for Spatio-Temporal Market Analysis (SDformerFlow)

Neural Networks in Trading: A Spiking Architecture for Spatio-Temporal Market Analysis (SDformerFlow)

The article presents an adaptation of the SDformerFlow spiking architecture for the task of dense analysis of price micro-movements. The spatio-temporal structure provides a high level of detail, while the spiking logic ensures computational efficiency and the ability to work with sparse, pulse-like data. As a result, traders gain access to a tool that detects even the slightest shifts in liquidity and provides the foundation for more accurate and consistent real-time decisions.
preview
Local Outlier Factor: Density-Based Anomaly Detection in Native MQL5

Local Outlier Factor: Density-Based Anomaly Detection in Native MQL5

This article builds a native MQL5 LOF engine without DLLs, ALGLIB or ONNX. Bars are mapped to five standardized features; k‑NN reachability and density produce a scale‑free LOF score, and the alarm level is a moving quantile of the reference cloud. The score gates only new entries in an EMA‑cross EA, with an indicator for charting and a script for independent checks on XAUUSD, EURUSD and GBPUSD.
preview
Property-Based Testing for Trading Rules in MQL5 (Part 1): Generate Market Scenarios, Test Invariants, Find Edge Cases

Property-Based Testing for Trading Rules in MQL5 (Part 1): Generate Market Scenarios, Test Invariants, Find Edge Cases

Property-based tests exercise a sizing rule across thousands of generated scenarios instead of a few hand-picked cases. A deterministic MQL5 runner creates seeded symbol contracts, checks eight risk-volume properties, and writes text and CSV reports for reproducible evidence. A second script intentionally rounds volume the wrong way, replays the failing seed, and shrinks the counterexample to the half-step boundary, making the defect minimal and diagnosable.
preview
Building a FIFO-Compliant Position Management Layer for NFA-Regulated MQL5 Accounts

Building a FIFO-Compliant Position Management Layer for NFA-Regulated MQL5 Accounts

This article shows how to make EA close operations comply with broker-enforced FIFO (ACCOUNT FIFO CLOSE) on hedging accounts, so naive exits stop failing. It introduces CFifoPositionQueue to order an EA's own tickets by time and CFifoComplianceGuard to execute closes in two modes: strict reject or auto-cascade, with optional per-direction scope. The guard re-verifies eligibility before each step, normalizes volumes, and inspects real server retcodes. You get reusable code, tests, and clear limits.
preview
Neural Networks in Trading: A Spatio-Temporal State-Space Model for Financial Data Analysis (E-STMFlow)

Neural Networks in Trading: A Spatio-Temporal State-Space Model for Financial Data Analysis (E-STMFlow)

We invite you to explore the E-STMFlow framework, which effectively processes event streams by extracting informative embeddings, filtering out noise, and identifying key movements. Its architecture makes it possible to identify complex relationships between features and provides scalability, accuracy, and high computational efficiency for intelligent analysis and forecasting.
preview
Integrating MQL5 with Data Processing Packages (Part 11): Multi-Timeframe Causality Detection using Granger Analysis

Integrating MQL5 with Data Processing Packages (Part 11): Multi-Timeframe Causality Detection using Granger Analysis

This article implements a multi‑timeframe Granger causality monitor for MetaTrader 5. A Jupyter notebook tests predefined timeframe pairs, selects lags, applies multiple‑testing control, and exports a calibration table. An MQL5 Expert Advisor reloads the setup, recomputes the F‑test live on rolling windows, and marks pairs VALID/INVALID to gate its vote‑based BUY/SELL generator. The workflow shows alignment rules, live/offline parity, and a filtered vs unfiltered comparison on EURUSD.
preview
Temporal Causality Audit in MQL5: Validating Recorded Dependencies Against the Decision Time

Temporal Causality Audit in MQL5: Validating Recorded Dependencies Against the Decision Time

Look-ahead errors arise when a decision consumes values that did not yet exist, such as a partially formed higher-timeframe bar. This MQL5 library logs input timing metadata and validates declarations against the decision time with eight ordered rules, returning PASS, WARNING, or FAIL and a named violation. A demo EA plus twelve deterministic tests at a fixed timestamp illustrate correct and failing cases.
preview
Overcoming Accessibility Problems in MQL5 Trading Tools (Part VIII): Building a Floating Risk Management Calculator Module for Any EA

Overcoming Accessibility Problems in MQL5 Trading Tools (Part VIII): Building a Floating Risk Management Calculator Module for Any EA

A reusable MQL5 component measures floating P/L with swap, gross loss, two stop‑loss quantities, equity gap, margin level, and stop coverage, then classifies results for selected positions and the whole account. The snapshot records validity and readable reasons, supporting a quote‑age policy and missing‑stop handling. Integrate it into an Expert Advisor and block new exposure when thresholds or data checks fail.
preview
Neural Networks in Trading: A Spatio-Temporal State Model for Financial Data Analysis (Conclusion)

Neural Networks in Trading: A Spatio-Temporal State Model for Financial Data Analysis (Conclusion)

We present an adaptation of the E-STMFlow framework — a modern solution for building autonomous trading systems. In this article, we complete the implementation of the approaches proposed by the framework's authors. The test results demonstrate steady capital growth, minimal drawdowns, and a predictable distribution of risk, confirming the practical effectiveness of the approach and opening up opportunities for further optimization of the strategy.
preview
Developing Statistical Market Inflection Forecasting Indicator

Developing Statistical Market Inflection Forecasting Indicator

An MQL5 indicator forecasts where a movement is likely to terminate and how far the opposite leg has typically traveled, using statistics from completed moves on the same symbol and timeframe. It detects confirmed pivots, takes a single snapshot, selects similar historical observations, and reads entry, stop loss, and take profit from their distributions. Empirical hit rates come from a chronological replay without look‑ahead, and resolved forecasts leave the chart with an option to review them.
preview
Neural Networks in Trading: Bidirectional Adaptive Temporal Correlation (BAT)

Neural Networks in Trading: Bidirectional Adaptive Temporal Correlation (BAT)

The article presents the BAT framework, which enables accurate and adaptive modeling of temporal dynamics. Using bidirectional temporal correlation, BAT transforms sequential changes in market data into structured, informative representations. The model combines high computational efficiency with the ability to integrate deeply into trading systems, enabling the identification of both short-term and long-term price movement patterns.
preview
Building a Prop Firm Compliance Monitor in MQL5 (Part 4): Economic Calendar and Account Exposure Monitoring

Building a Prop Firm Compliance Monitor in MQL5 (Part 4): Economic Calendar and Account Exposure Monitoring

This article explains exposure-aware economic news monitoring for Prop Firm Guard in MetaTrader 5. The EA builds a unique currency set from supported open positions, treats XAUUSD as USD exposure, filters Economic Calendar events by currency, minimum importance, specific scheduled datetime, and search horizon, and selects the nearest qualifying event. The resulting countdown and restriction window are integrated into the EA through OnInit() and OnTimer().
preview
Causal Savitzky-Golay Kinematics in MQL5: Non-Repainting Velocity and Acceleration from Local Polynomial Fits

Causal Savitzky-Golay Kinematics in MQL5: Non-Repainting Velocity and Acceleration from Local Polynomial Fits

We present CSavGolFilter, a causal Savitzky–Golay implementation for MQL5 that evaluates a local polynomial at the most recent closed bar. It delivers smoothed price, velocity, and acceleration via precomputed convolution kernels, avoiding per-tick matrix work. The package includes an indicator, a simple EA, and a self-test that proves the non-repainting property and validates kernel identities.
preview
Bacterial Evolutionary Algorithm (BEA)

Bacterial Evolutionary Algorithm (BEA)

The article focuses on the Nawa–Furuhashi Bacterial Evolutionary Algorithm (BEA) and its two key operators: segmental bacterial mutation for local optimization and horizontal gene transfer for the exchange of successful solution fragments. We implement BEA within the C_AO framework as a finite-state machine with a fixed evaluation budget, test it on Hilly, Forest, and Megacity, and explain the terminological distinction from the Numaoka model.
preview
Neural Networks in Trading: Bidirectional Adaptive Temporal Correlation (Main Components)

Neural Networks in Trading: Bidirectional Adaptive Temporal Correlation (Main Components)

We continue implementing the BAT framework in MQL5, showing how bidirectional correlation and the SATMA module enable the analysis of market dynamics in the context of the current state. Key architectural solutions that enable the framework to be adapted for financial data analysis are presented.