Skip to content
All library documents

Building an MQL5 Depth of Market Class and Trading Panel

Article MQL5 articles

Summary

This article explains how MetaTrader 5 exposes exchange order book data and how to build a reusable MQL5 class to simplify access. It describes subscribing to book-change events for selected symbols, retrieving second-level quotes, and organizing price levels and volumes so an Expert Advisor or indicator can use them without repeating low-level calculations.

The CMarketBook class supports common tasks such as locating best bid and ask levels, calculating spread and volume-related deviation, and displaying a compact DOM panel. The article outlines panel features including sorting or presenting levels, volume histograms, and order totals. Its evidence is an implementation walkthrough and example indicator, rather than a trading-performance evaluation. The author emphasizes efficient processing because book updates are frequent, and notes that the sample panel is basic and intended as a foundation for system-specific extensions. Availability and completeness of DOM data depend on the connected broker and exchange feed.

Key ideas

  • Subscribe only to symbols whose order book updates the program needs to process.
  • A wrapper class can centralize calculations on book prices, levels, and volumes.
  • A chart indicator can render selected order book information as a compact panel.
  • Frequent book changes make efficient event handling and iteration important.
  • The described class is an extensible programming foundation, not a tested trading strategy.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.