The article presents a live‑only MQL5 indicator that converts MarketBook data into a price ladder with tick‑based bucketing, per‑level aggregation, outward cumulative columns, and top‑3 cluster marking per side. A canvas panel renders the ladder, spread, and diagnostics, avoiding empty or misleading displays when DOM is missing. Logic is isolated in tested classes, providing a clear, reusable structure for DOM visualization.
The terminal exposes the Depth of Market (DOM) through MarketBookGet(), which fills an array of MqlBookInfo structures. Each entry carries a type, a price, and a volume. The array is flat, so the same price can appear in several entries, and the documentation page does not promise any order.
A flat array is hard to read. Useful questions need a price ladder: volume grouped by price level, cumulative volume outward from the best prices, and the largest levels marked. This article builds that aggregation and shows it on a live panel drawn with CCanvas.
Before the code, note two constraints. First, a server may provide no DOM data for a symbol. The subscription can fail with error 4901. The snapshot may be empty or may contain too few valid levels. The indicator reports these cases on the panel as "DOM unavailable" or "No DOM data", and it does not draw an empty ladder as if it were real data. The minimum number of levels is the input InpMinLevels, and it counts both sides together.
Second, the Strategy Tester does not replay DOM data in the way the live terminal provides it. The demonstration is therefore live only, and this article does not suggest backtesting the result.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Building a Price Ladder Aggregator for Depth-of-Market Analysis in MQL5.
The terminal exposes the Depth of Market (DOM) through MarketBookGet(), which fills an array of MqlBookInfo structures. Each entry carries a type, a price, and a volume. The array is flat, so the same price can appear in several entries, and the documentation page does not promise any order.
A flat array is hard to read. Useful questions need a price ladder: volume grouped by price level, cumulative volume outward from the best prices, and the largest levels marked. This article builds that aggregation and shows it on a live panel drawn with CCanvas.
Before the code, note two constraints. First, a server may provide no DOM data for a symbol. The subscription can fail with error 4901. The snapshot may be empty or may contain too few valid levels. The indicator reports these cases on the panel as "DOM unavailable" or "No DOM data", and it does not draw an empty ladder as if it were real data. The minimum number of levels is the input InpMinLevels, and it counts both sides together.
Second, the Strategy Tester does not replay DOM data in the way the live terminal provides it. The demonstration is therefore live only, and this article does not suggest backtesting the result.
Author: Ushana Kevin Iorkumbul