MQL4 and MQL5 Programming Articles

icon

Study the MQL5 language for programming trading strategies in numerous published articles mostly written by you - the community members. The articles are grouped into categories to help you quicker find answers to any questions related to programming: Integration, Tester, Trading Strategies, etc.

Follow our new publications and discuss them on the Forum!

Add a new article
latest | best
preview
MQL5 Trading Tools (Part 25): Expanding to Multiple Distributions with Interactive Switching

MQL5 Trading Tools (Part 25): Expanding to Multiple Distributions with Interactive Switching

In this article, we expand the MQL5 graphing tool to support seventeen statistical distributions with interactive cycling via a header switch icon. We add type-specific data loading, discrete and continuous histogram computation, and theoretical density functions for each model, with dynamic titles, axis labels, and parameter panels that adapt automatically. The result lets you overlay distribution models on the same sample and compare fit across families without reloading the tool.
preview
Neural Networks in Trading: Adaptive Detection of Market Anomalies (DADA)

Neural Networks in Trading: Adaptive Detection of Market Anomalies (DADA)

We invite you to get acquainted with the DADA framework, which is an innovative method for detecting anomalies in time series. It helps distinguish random fluctuations from suspicious deviations. Unlike traditional methods, DADA is flexible and adapts to different data. Instead of a fixed compression level, it uses several options and chooses the most appropriate one for each case.
preview
MetaTrader 5 Machine Learning Blueprint (Part 9): Integrating Bayesian HPO into the Production Pipeline

MetaTrader 5 Machine Learning Blueprint (Part 9): Integrating Bayesian HPO into the Production Pipeline

​This article integrates the Optuna hyperparameter optimization (HPO) backend into a unified ModelDevelopmentPipeline. It adds joint tuning of model hyperparameters and sample-weight schemes, early pruning with Hyperband, and crash-resistant SQLite study storage. The pipeline auto-detects primary vs. secondary models, prepends a fitted column-dropping preprocessor for safe inference, supports sequential bootstrapping, generates an Optuna report, and includes bid/ask and LearnedStrategy links. Readers get faster, resumable runs and deployable, self-contained models.
preview
Building a Research-Grounded Grid EA in MQL5: Why Most Grid EAs Fail and What Taranto Proved

Building a Research-Grounded Grid EA in MQL5: Why Most Grid EAs Fail and What Taranto Proved

This article implements a regime-adaptive grid trading EA based on the PhD research of Aldo Taranto. It presents a regime‑adaptive grid trading EA that constrains risk through restartable cycles and equity‑based safeguards. We explain why naive grids fail (variance growth and almost‑sure ruin), derive the loss formula for real‑time exposure, and implement regime‑aware gating, ATR‑dynamic spacing, and a live kill switch. Readers get the mathematical tools and production patterns needed to build, test, and operate a constrained grid safely.
preview
Introduction to MQL5 (Part 43): Beginner Guide to File Handling in MQL5 (V)

Introduction to MQL5 (Part 43): Beginner Guide to File Handling in MQL5 (V)

The article explains how to use MQL5 structures with binary files to persist Expert Advisor parameters. It covers defining structures, accessing members, and distinguishing simple from complex layouts, then writing and reading entire records using FileWriteStruct and FileReadStruct in FILE BIN mode. You will learn safe patterns for fixed-size data and how shared storage (FILE COMMON) enables reuse across sessions and terminals.
preview
Developing Market Entropy Indicator: Trading System Based on Information Theory

Developing Market Entropy Indicator: Trading System Based on Information Theory

This article explores the development of a Market Entropy Indicator based on principles from Information Theory to measure the uncertainty and information content within financial markets. By applying concepts such as Shannon Entropy to price movements, the indicator quantifies whether the market is structured (trending), transitioning, or chaotic.
preview
Creating Custom Indicators in MQL5 (Part 10): Enhancing the Footprint Chart with Per-Bar Volume Sentiment Information Box

Creating Custom Indicators in MQL5 (Part 10): Enhancing the Footprint Chart with Per-Bar Volume Sentiment Information Box

The article enhances an MQL5 footprint indicator with a compact box above each candle that summarizes net delta, total volume, and buy/sell percentages. We implement supersampled anti‑aliased rendering, rounded corners via arc and quadrilateral rasterization, and per‑pixel alpha compositing. Supporting utilities include ARGB conversion, scanline fills, and box‑filter downsampling. The box delivers fast sentiment reads that stay legible across zoom levels.
preview
Coral Reefs Optimization (CRO)

Coral Reefs Optimization (CRO)

The article presents a comprehensive analysis of the Coral Reef Optimization (CRO) algorithm, a metaheuristic method inspired by the biological processes of coral reef formation and development. The algorithm models key aspects of coral evolution: broadcast spawning, brooding, larval settlement, asexual reproduction, and competition for limited reef space. Particular attention is paid to the improved version of the algorithm.