Programming Articles on MQL5.com
2026.09.18
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.
2026.09.18
We consider a BAS+PSO (BSO) hybrid, where BAS provides a local direction signal and PSO facilitates the exchange of best solutions within the swarm. The article presents a mathematical model, pseudocode, an implementation of the class in MQL5, and test results from a standard test bench. This material allows reproducing the algorithm, configuring its parameters, and understanding how three objective-function evaluations per iteration affect efficiency.
2026.09.18
The series develops machine learning in 100% native MQL5 with no external dependencies. Part 1 delivers logistic regression from first principles: a CLogReg class with standardization, a stable sigmoid, SGD training, and model persistence, plus a script that builds ATR-normalized features, labels the next bar, and tests out-of-sample against a baseline. Readers get a compact include file and a clear template for leakage-free evaluation.
2026.09.18
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.
2026.09.18
In this article, we will clearly and simply demonstrate and explain how to remove a node from a tree. This process usually confuses beginners rather than helping them understand how it's done and why it needs to be done that way.
2026.09.18
In the previous article, we configured the indicator to display the financial result. However, not everyone likes using this display mode. The reasons differ from one trader to another, although in some cases they seem quite reasonable and justified to me. Adapting the code to provide this capability is by no means one of the most difficult tasks. It's actually pretty simple. In this article, we'll look at how to do this.
2026.09.17
There are more than 3,390 articles published on site
2026.09.17
This article implements a typed message bus over Windows named pipes to replace MetaTrader's untyped GlobalVariables for inter‑EA communication. A broker EA manages the server and registry, serves multiple slave EAs, and responds with a live, per‑symbol‑attributed portfolio risk measure. It also explains the non-blocking accept pattern that preserves terminal responsiveness, and includes a dashboard and a test script.
2026.09.17
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.
2026.09.17
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.
2026.09.17
This article presents a native MQL5 implementation of the ZeroMQ Message Transfer Protocol (ZMTP) built on raw MQL5 sockets. It explains the REQ/REP pattern via the CZmqReqSocket class, including framing, handshake, and strict send/receive alternation. A practical pipeline shows an MQL5 script streaming returns to a Python/R server running MS‑GARCH and receiving regime probabilities, enabling integration without DLLs.
2026.09.17
A step-by-step guide to a native Isolation Forest in MQL5 focused on execution metrics rather than price. It details five features, tree construction and path‑length scoring, rolling‑window training, CSV logging, and FILE_COMMON persistence, all integrated into OnTradeTransaction(). The resulting circuit breaker flags unusual fills in real time and applies controlled responses to stabilize live trading under changing execution conditions.
2026.09.17
We convert the Part 15 decision‑forest classifier into a regime‑adaptive Expert Advisor that decouples statistical inference from trading authority. The EA trains on completed bars, scores each new completed bar, and confirms stable bullish, neutral, or bearish regimes before acting. It then applies spread, ownership, risk, and execution checks to authorize opening, holding, closing, or blocking a position.
2026.09.17
The article details a native MQL5 Kafka producer that speaks the wire protocol over raw TCP. It implements RecordBatch v2 encoding, varints, and CRC32C, and adds batching, acks, and retry logic, all without a sidecar or DLL. Use it to publish JSON-structured trading signals from a single terminal to Kafka, where dashboards and other services subscribe independently.
2026.09.17
This article explains Monte Carlo simulation and analysis for trading and guides you through a Python tool that ingests MetaTrader 5 HTML reports. It generates many randomized equity paths, then summarizes them with max drawdown, bust/profit rates, and percentile envelopes around the mean curve. The workflow helps you assess uncertainty, separate normal behavior from outliers, and size positions accordingly.
2026.09.17
A hybrid architecture based on Llama 3.2 and SEAL is being tested on eight currency pairs (M15), with forward-period data isolation and information leakage control. The methodology combines adversarial self-play, curriculum learning, and class balancing to ensure stable training. The experiments confirm the gap between forecast accuracy and actual returns, providing readers with practical guidelines for testing strategies and accurately assessing their generalizability.
2026.09.16
The article discusses the Butterfly Optimization Algorithm, which is based on modeling foraging using the sense of smell. We will analyze the original formulas, identify and correct errors in motion equations, add a mechanism for maintaining population diversity, and present the test results.
2026.09.16
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.
2026.09.16
There are more than 3,380 articles published on site
2026.09.16
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.
2026.09.16
We turn eigenvalues from a covariance matrix into a normalized spectral‑entropy score that measures how evenly variance is spread across factors. SpectralEntropyCalculator.mq5 compares two portfolios in one run, using native vector summation, ArraySort()-based ordering, element‑wise division, and the Shannon entropy formula. The report makes dominant factors visible and enables quick, repeatable checks of diversification quality.
2026.09.16
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.
2026.09.16
We present an MQL5 script that converts closed trade history into comparable metrics: expectancy in currency, pips, and R-multiples, plus a sample-aware win rate via the Wilson interval. These inputs form a conservative, dimensionless Trade Quality Score. The tool draws a CCanvas panel, prints an Experts-tab report, and supports an hour-based session filter to analyze a defined trading window alongside full-history results.
2026.09.16
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.
2026.09.16
In this article, we will make the necessary changes so that the position indicator displays the financial result. This way, the trader will be able to get an idea of the financial result of an open position. In addition, I will tell you something that many people do not know, even those who have been using MQL5 for a long time: how to use static variables to share memory and avoid declaring a global variable in the main code.
2026.09.16
In this article, we will return to the tree implementation. Now that we are familiar with the basic principles of constructors and destructors, we can finally fix the code presented in the previous article. Get ready for a real adventure in MQL5 programming.
2026.09.15
Most read articles this month
How to purchase a trading robot from the MetaTrader Market and to install it?
A product from the MetaTrader Market can be purchased on the MQL5.com website or straight from the MetaTrader 4 and MetaTrader 5 trading platforms. Choose a desired product that suits your trading style, pay for it using your preferred payment method, and activate the product.
How to Test a Trading Robot Before Buying
Buying a trading robot on MQL5 Market has a distinct benefit over all other similar options - an automated system offered can be thoroughly tested directly in the MetaTrader 5 terminal. Before buying, an Expert Advisor can and should be carefully run in all unfavorable modes in the built-in Strategy Tester to get a complete grasp of the system.
2026.09.15
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.
2026.09.15
In this article, I will try to explain as simply as possible how messaging between applications can be used. The goal is to enable you to create something workable in the simplest and most efficient way possible whenever you can. I am not sure if I will be able to convey the idea behind this concept, since it is not that easy to understand for someone encountering it for the first time. In addition, I will take this opportunity to show you how to modify the replay/simulation system so you can debug an Expert Advisor or any other code you are developing. And all of this is just as simple and straightforward.
2026.09.15
In this article, we will explore the best ways to manage code when working with object-oriented programming. Although we are just beginning to learn about object-oriented programming, what we will cover here will help you understand its various aspects. This will also help dispel any doubts that may arise later.
2026.09.15
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.
2026.09.15
There are more than 3,370 articles published on site
2026.09.15
The article proposes a hybrid approach to algorithmic trading based on quantum encoding of market states, Double DQN with a prioritized experience replay buffer, and an LLM acting as a contextual EA. The SEAL methodology enables asynchronous continued training of the agent without halting trading. A lightweight Q-learning filter (USE/SKIP/REDUCE) controls signal execution at the meta-level. Practical details are provided on integrating the system with the MetaTrader 5 trading platform, along with a scheme for adapting it to market regime shifts.
2026.09.15
In this article, we will implement a number of improvements to ensure that the position indicator accurately reflects the actual state on the trading server in terms of open positions and their current state. I should point out that the applications shown here are in no way intended to replace any of the elements available in MetaTrader 5. They should also not be used without due caution and a balanced approach, since their purpose is to provide educational code—that is, code intended solely for learning how the system works. The reason I call this code “educational” is that, in some cases, using messages is not the best way to implement certain functions.
2026.09.15
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.
2026.09.15
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.
2026.09.15
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.
2026.09.14
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.
2026.09.14
In this article, we will examine the Finite Volume Elements (FVE) indicator, which helps identify genuine capital flows in the market. We will implement FVE for MetaTrader 5 and review recommendations for using it in trading.
2026.09.14
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.
2026.09.14
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.
2026.09.14
We decode ONNX files in pure MQL5 by implementing a Protocol Buffers reader from scratch. We generate a sample network in Python, verify it in Netron, and then parse the same binary to recover graph nodes, connections, weight tensors, and input/output shapes. The result is a MetaTrader 5 program that inspects a trained model's structure before inference, without any external libraries.
2026.09.13
Most read articles this week
How to purchase a trading robot from the MetaTrader Market and to install it?
A product from the MetaTrader Market can be purchased on the MQL5.com website or straight from the MetaTrader 4 and MetaTrader 5 trading platforms. Choose a desired product that suits your trading style, pay for it using your preferred payment method, and activate the product.
How to Test a Trading Robot Before Buying
Buying a trading robot on MQL5 Market has a distinct benefit over all other similar options - an automated system offered can be thoroughly tested directly in the MetaTrader 5 terminal. Before buying, an Expert Advisor can and should be carefully run in all unfavorable modes in the built-in Strategy Tester to get a complete grasp of the system.
2026.09.13
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.
2026.09.13
There are more than 3,360 articles published on site
2026.09.13
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.
2026.09.13
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.
2026.09.12
SEAL (Self-Evolving Adaptive Learning) is a system for the continuous adaptation of large language models (LLMs) for algorithmic trading, designed to address the problem of rapid model degradation in changing markets. Instead of periodic retraining, which takes hours and erases old patterns, SEAL learns from every closed trade, maintains priority memory for important examples, and automatically initiates incremental fine-tuning when accuracy drops or a market regime change occurs.
2026.09.12
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.
2026.09.11
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.