Skip to content
All library documents

Representing Depth of Market Orders as Typed Objects in MQL5

Article MQL5 articles

Summary

This installment describes an object model for handling Depth of Market data in an MQL5 library. It proposes representing each order in a market book with its type, price, volume, extended-precision volume, and buy or sell status. A base abstract order class is paired with four specialized descendants for limit and market buy and sell orders. The broader design also outlines snapshot objects, per-symbol time series, and a collection spanning subscribed symbols.

The implementation obtains book data through the platform's market book functions when a book event fires, then organizes and displays a snapshot. The article reports a test in which an EA subscribes to two symbols and prints the observed orders for one symbol, including their sides, prices, and sizes. This illustrates event-driven collection and organization of book data, not a trading strategy or predictive result. The DOM classes are explicitly described as under development, and the article advises against using them in custom programs at that stage. Its main value is in understanding how order book events and order records can be modeled in a trading library.

Key ideas

  • A DOM event can trigger retrieval of a current order book snapshot for a subscribed symbol.
  • Each order record includes type, price, volume, and an indication of buy or sell direction.
  • The design uses a base order class with specialized classes for four book order types.
  • Snapshots can be organized into per-symbol time series and collections across subscribed symbols.
  • The demonstrated output validates data organization, while the developing library is not presented as a trading strategy.

Tags

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