//+------------------------------------------------------------------+
//|                                                     DomTypes.mqh |
//+------------------------------------------------------------------+
#ifndef DOM_TYPES_MQH
#define DOM_TYPES_MQH

//--- tolerance used when two volumes are compared for a tie
#define DOM_VOLUME_EPS     1.0e-9
//--- number of clusters marked on each side of the book
#define DOM_CLUSTER_COUNT  3

//+------------------------------------------------------------------+
//| Data status shown in the panel header                            |
//+------------------------------------------------------------------+
enum ENUM_DOM_STATUS
  {
   DOM_STATUS_WAITING          = 0,   // no book has been processed yet
   DOM_STATUS_SUBSCRIBE_FAILED = 1,   // ::MarketBookAdd() returned false
   DOM_STATUS_READ_FAILED      = 2,   // ::MarketBookGet() failed or data could not be processed
   DOM_STATUS_NO_DATA          = 3,   // empty book or too few valid levels
   DOM_STATUS_OK               = 4    // a usable ladder was built
  };

//+------------------------------------------------------------------+
//| One price level of the ladder                                    |
//| cluster_rank: 0 is a placeholder meaning "not a cluster"         |
//+------------------------------------------------------------------+
struct SDomLevel
  {
   long              tick_index;      // price level expressed as a tick count
   double            price;           // price of the level
   double            volume;          // summed volume at the level
   double            cum_volume;      // cumulative volume outward from the best price of its side
   bool              is_bid;          // true for the bid side, false for the ask side
   int               cluster_rank;    // 0 = not a cluster, 1..3 = rank within its side
  };

//+------------------------------------------------------------------+
//| Counters filled while one snapshot is aggregated                 |
//+------------------------------------------------------------------+
struct SDomStats
  {
   int               total_entries;   // entries in the raw snapshot
   int               used_entries;    // entries accepted for aggregation, counted before equal prices are merged into levels
   int               skipped_price;   // invalid or non-positive price
   int               skipped_volume;  // negative or non-finite volume
   int               skipped_zero;    // zero volume
   int               market_orders;   // BOOK_TYPE_SELL_MARKET and BOOK_TYPE_BUY_MARKET entries
   int               unknown_type;    // type value outside ENUM_BOOK_TYPE
  };

#endif
//+------------------------------------------------------------------+