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
Deterministic Dendritic Cell Algorithm (dDCA)

Deterministic Dendritic Cell Algorithm (dDCA)

The article presents an adaptation of the Deterministic Dendritic Cell Algorithm (dDCA) for continuous optimization problems. The algorithm, inspired by the immune system's Danger Theory, uses a signal accumulation mechanism to automatically balance exploration and exploitation within the search space.
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
A Reusable Breakeven Manager in MQL5 with Spread Compensation

A Reusable Breakeven Manager in MQL5 with Spread Compensation

A robust breakeven implementation for MQL5 is built around live spread sampling and correct pip-to-price conversion by symbol digits. CBreakevenManager moves SL to open_price ± spread ± buffer once a real‑pip activation threshold is reached and prevents duplicate modifications. A demo EA shows the behavioral difference versus a naive breakeven, and a script verifies core calculations.
preview
Foundation Models for Trading (Part II): Decoding, Autoregression, and an Exact KV-Cache

Foundation Models for Trading (Part II): Decoding, Autoregression, and an Exact KV-Cache

We complete the native MQL5 port of Kronos: the decoder, the predictor's decode_s1 and decode_s2 stages with their cross-attention traps, and the autoregressive loop that produces a multi-bar forecast. Then we profile and make it roughly 4.5x faster with an exact KV-cache and pre-transposed weights, verifying every stage against PyTorch.
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
Ebola Optimization Search Algorithm (EOSA)

Ebola Optimization Search Algorithm (EOSA)

The article examines the EOSA algorithm, which is inspired by the mechanisms of Ebola virus transmission: short-distance transmission through close contact (exploitation) and long-distance transmission through travel (exploration). An analysis of the original publication revealed critical issues in the mathematical formulas and an epidemiological model that was impractical to implement, which required a significant overhaul of the algorithm to produce a workable implementation.
preview
Building Your Personal Expert Advisor (Part 3): Risk Management II—Margin and Allowable Risk

Building Your Personal Expert Advisor (Part 3): Risk Management II—Margin and Allowable Risk

Risk-based lot sizing can still exceed what free margin allows. The article adds a margin-aware cap using OrderCalcMargin(), an optional adaptive cap that scales with ACCOUNT MARGIN LEVEL, and a single pre-trade validation gate that unifies position limits, risk sizing, and margin checks. Readers get concrete code to prevent order rejections and over-committing margin, with clear logs when a trade is reduced or skipped.
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
Cricket Algorithm (CA)

Cricket Algorithm (CA)

The article discusses the Cricket Algorithm, a metaheuristic optimization method that combines elements of the Bat Algorithm and the Firefly Algorithm with the physical laws governing the propagation of sound in the atmosphere. The algorithm simulates the behavior of crickets that navigate by the chirping of their conspecifics, using Dolbear's law and acoustic formulas to guide the search for best solutions.
preview
Adaptive Position Sizing in MQL5: A Prototype Risk Engine with Generalized Kelly and Bootstrap Calibration

Adaptive Position Sizing in MQL5: A Prototype Risk Engine with Generalized Kelly and Bootstrap Calibration

This article presents a modular position sizing engine for MetaTrader 5 that operates on normalized R-multiples. A layered pipeline combines enriched trade statistics, a generalized Kelly edge estimate, volatility-aware adjustment, Monte Carlo calibration under ruin and drawdown limits, a continuous risk policy, an exposure guard, and a broker-aware lot calculator. The output is a broker-valid lot size with an optional CSV audit trail, providing a transparent prototype for implementing modern risk controls in native MQL5.
preview
Building a Prop-Firm Compliance Monitor in MQL5 (Part 1): Account Rules and Persistent Settings

Building a Prop-Firm Compliance Monitor in MQL5 (Part 1): Account Rules and Persistent Settings

Establishes the persistence foundation for a prop-firm compliance EA in MetaTrader 5. It introduces rule inputs and status enums, separates live account state from stored settings, validates percentages and thresholds, and implements SQLite open/close, schema creation, and prepared save/load operations. Using the account login and server as a composite key, the EA restores existing settings and updates them when inputs change.
preview
The MQL5 Standard Library Explorer (Part 15): Building a Market-Regime Classifier with dataanalysis.mqh

The MQL5 Standard Library Explorer (Part 15): Building a Market-Regime Classifier with dataanalysis.mqh

This part focuses on practical data analysis in MQL5 with dataanalysis.mqh. We prepare a labeled dataset from bars, apply normalization, explore redundancy with PCA, and train a decision forest to classify future bar regimes. The article shows how to obtain out-of-bag estimates and permutation importance, helping you validate the model and understand which inputs matter most.
preview
Enhanced Colliding Bodies Optimization (ECBO)

Enhanced Colliding Bodies Optimization (ECBO)

The article discusses the Colliding Bodies Optimization (CBO) algorithm, which is based on the physics of one-dimensional collisions between bodies. The basic version of the algorithm does not include any configurable parameters, which makes it simple. Therefore, the enhanced ECBO version — supplemented with Colliding Memory and a crossover mechanism — was used as the basis for the implementation, allowing the algorithm to achieve respectable results and earn a place in the ranking table.