Skip to content
All library documents

Building Depth of Market Snapshot and Series Classes in MQL5

Article MQL5 articles

Summary

This installment of the DoEasy library series describes an object model for storing Depth of Market data over time. Each MarketBookGet result, received when an OnBookEvent occurs, is represented as a snapshot containing individual order objects. Successive snapshots are held in a bounded series for each subscribed symbol, with the series intended to live in a broader DOM data collection.

The article details library changes needed to support this design: adding a millisecond snapshot-time property to DOM orders, sorting and search criteria for that property, and a maximum stored snapshot count. It also describes the snapshot and series classes and demonstrates the resulting data through a test EA, including a sample EURUSD book and counts accumulated during operation. The series has a default capacity intended to cover roughly one or two trading days, but retention is capped by count, not yet linked to requested days. The author says DOM classes are still under development and advises against using them in custom programs at this stage.

Key ideas

  • Each market book event can be captured as a snapshot composed of individual DOM order objects.
  • A per-symbol series stores successive snapshots in a bounded dynamic list.
  • Adding millisecond timestamps to order objects enables time-based sorting and searching of snapshots.
  • The demonstrated library uses a maximum snapshot capacity, while day-based retention is not yet implemented.
  • The DOM classes remain under development and are not recommended for custom programs in this version.

Tags

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