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
Beyond REST and ZeroMQ: Building a gRPC/Protocol Buffers Bridge for Real-Time MetaTrader 5–Python Inference

Beyond REST and ZeroMQ: Building a gRPC/Protocol Buffers Bridge for Real-Time MetaTrader 5–Python Inference

This article defines a Protocol Buffers contract for the MetaTrader 5-Python boundary and implements a length-prefixed Protobuf-over-TCP client in MQL5, since MQL5 cannot speak real gRPC natively. A small Python shim relays those frames to a genuine grpc.aio server, unary today, with streaming already live on the backend. You get schema-enforced, strongly-typed messages, explicit errors, retry/backoff, and a Strategy Tester cache for reproducible backtests where sockets don't run.
preview
Implementing and Comparing Five Historical Volatility Estimators in MQL5

Implementing and Comparing Five Historical Volatility Estimators in MQL5

The study implements five historical-variance estimators in MQL5 and evaluates their one-session-ahead persistence forecasts for EURUSD D1 sessions using an M1 realized-variance proxy. Deterministic tests cover formulas, chronological order, and target construction. A configurable indicator, comparison scripts, and CSV outputs provide reproducible losses, calibration diagnostics, a common‑target mask, and sensitivity to the estimation window.
preview
Uncertainty as a Model (Part 2): Dependence Among Random Variables — From Correlation to Copulas

Uncertainty as a Model (Part 2): Dependence Among Random Variables — From Correlation to Copulas

The second part of the series examines the mathematical framework for multivariate random variables, which is necessary for analyzing the dependence and joint behavior of market assets. This section describes joint distribution functions, the concepts of marginal and conditional distributions, and the conditions for dependence and independence of variables. The theoretical material is based on extending the analogy between probability and mass to multidimensional space. Particular attention is given to measures of association: from classical linear covariance and correlation to modern tools such as copulas and Shannon mutual information.
preview
Symbolic Fourier Approximation in MQL5: Benchmarking SFA Against SAX

Symbolic Fourier Approximation in MQL5: Benchmarking SFA Against SAX

We implement Symbolic Fourier Approximation in MQL5 and compare it to SAX under a shared harness on identical price windows. SFA keeps low‑frequency Fourier coefficients and learns per‑position bins (MCB), with a proven, sound lower bound. The measurements show how the same bit budget behaves under different splits of word length and alphabet, and give a practical rule for choosing settings for your symbol.
preview
Trade Duration vs Profitability Scatter Plot Indicator in MQL5

Trade Duration vs Profitability Scatter Plot Indicator in MQL5

The article presents a compact dashboard that relates trade duration to net profit using MQL5 and CCanvas. It pulls closed deals, derives duration in minutes, and renders a log‑scaled scatter by symbol, with an overlaid least‑squares line and R². A bucketed duration view identifies which hold‑time range produced the highest average result, helping assess exit timing.