Skip to main content

IMarketDepthIndicator

IMarketDepthIndicator provides programmatic access to the mzMarketDepth chart indicator. It exposes the real-time order book, historical DOM blocks, liquidity data, liquidity migration, and Level II histogram configuration.

Namespace: MZpack Inheritance: IMarketDepthIndicator : ITickIndicator : IIndicator Conditional: #if !FREE Source: MZpackBase/mzMarketDepth/IMarketDepthIndicator.cs

warning

Requires Level 2 data — live or replay only. Historical backtesting without Level 2 data will have empty DOM data.

Key Data Properties​

PropertyTypeDescription
RealtimeOrderBookIRealtimeOrderBookCurrent real-time DOM snapshot
BlocksDictionary<int, MarketDepthBlocks>Historical DOM blocks indexed by bar. Keyed by the aggregation zone when TicksPerLevel is above 1 — see Price Level Aggregation
OverallLiquiditySortedDictionary<int, IBarLiquidity>Aggregated DOM liquidity per bar
OverallMigrationsSortedDictionary<int, IBarLiquidity>Liquidity migration per bar
OverallMigrationsCloseSeries<double>Migration close values as a NinjaTrader Series

IRealtimeOrderBook​

The real-time order book interface exposes the current DOM state:

PropertyTypeDescription
TimeDateTimeSnapshot time
MarketDepthintConfigured depth
RealMarketDepthintActual available depth
BestBiddoubleBest bid price
BestOfferdoubleBest offer (ask) price
ResultMarketDepthResultSnapshot result status
RowsList<OrderBookPosition>[]Raw order book rows
MethodReturn TypeDescription
GetVolume(TradeSide side)longTotal volume on bid or ask side
GetVolume(int position, TradeSide side)longVolume at a specific depth level
GetPrice(int position, TradeSide side)doublePrice at a specific depth level
GetTotalVolume(TradeSide side)longTotal volume across all levels
GetTotalVolumeDepth(TradeSide side)longTotal volume within configured depth
AggregateCloneRows(TradeSide side)List<OrderBookPosition>Clone and aggregate rows for a side

DOM Configuration Properties​

PropertyTypeDescription
MaxMarketDepthintMaximum supported DOM depth, in ticks
TicksPerLevelintNumber of consecutive ticks merged into one DOM price zone. 1 means no aggregation
MultipleMarketMakerboolSupport for multiple market makers
ShowHistoricalDOMboolShow historical DOM visualization
HistoryDepthBarsintNumber of historical bars with DOM data
MarketDepthFilteringModeMarketDepthFilteringModeFiltering mode for DOM display

Price Level Aggregation​

TicksPerLevel merges N consecutive price ticks into one zone. The merge happens in the model, so everything fed by the order book — thresholds, color scales, historical blocks and migration markers — works on the merged zone volume.

  • MaxMarketDepth keeps counting ticks: depth is capped before the merge, so the side totals, the imbalance line and the quantitative depth metrics are identical at every setting.
  • Blocks is keyed by the zone — the lowest price of the zone for a Bid block, the highest one for an Ask block. The type and the shape of the dictionary are unchanged.
  • MarketDepthBlockDescriptor carries ZoneLow / ZoneHigh, and GetZone(out double low, out double high) reads both bounds as one consistent pair. OrderBookPosition exposes the same two properties. All of them equal Price when TicksPerLevel is 1.
  • The strategy values RealtimeBids and RealtimeOffers (and AggregateCloneRows) are deliberately left per tick.

Volume Display Properties​

PropertyTypeDescription
CodeExtremeVolumeboolHighlight extreme volumes
DisplayVolumedoubleDisplay volume threshold
ExtremeVolumedoubleExtreme volume threshold
DisplayVolumePercentageintDisplay threshold as a % of the volume range, counted from a reference volume rather than from the single biggest level
ExtremeVolumePercentageintExtremal threshold as a % of the displayed volume range, from the display threshold up to the biggest level on the chart
ShowVolumesboolShow volume values
ShowMaxVolumesboolShow maximum volumes

Liquidity Properties​

PropertyTypeDescription
ShowOverallLiquidityboolShow aggregated liquidity
ShowLiquidityMigrationboolShow per-bar migration
ShowOverallLiquidityMigrationboolShow overall migration
OverallLiquidityTypeOverallLiquidityMigrationTypeLiquidity aggregation type
OverallLiquidityMigrationTypeOverallLiquidityMigrationTypeMigration aggregation type
OverallLiquidityMigrationCumulateboolCumulate migration values
AddedVolumeFilterdoubleFilter for added volume
RemovedVolumeFilterdoubleFilter for removed volume
HoldHigherVolumeboolHold higher volume levels
HoldLevelsboolHold levels on chart

Imbalance Properties​

PropertyTypeDescription
ShowImbalanceboolShow DOM bid/ask imbalance
ImbalancePercentagedoubleImbalance ratio threshold

Level II Histogram Properties​

PropertyTypeDescription
ShowLevelIIHistogramboolShow Level II ladder histogram
LevelIIWidthintHistogram width in pixels
ShowLevelIIVolumesboolShow volume labels
ShowLevelIISideTotalPercentboolShow bid/ask total percentage
ShowLevelIIImbalanceboolShow Level II imbalance
LevelIIImbalanceRatiofloatImbalance ratio
ShowCumulativeLevelIIboolShow cumulative Level II

Example: Read DOM Bid/Ask Imbalance​

IMarketDepthIndicator mdIndicator = ...;

IRealtimeOrderBook book = mdIndicator.RealtimeOrderBook;
if (book == null) return;

// Total volume on each side
long totalBids = book.GetTotalVolume(TradeSide.Bid);
long totalAsks = book.GetTotalVolume(TradeSide.Ask);
double ratio = (double)totalBids / totalAsks;

// Read individual levels
for (int i = 0; i < book.RealMarketDepth; i++)
{
double bidPrice = book.GetPrice(i, TradeSide.Bid);
long bidVol = book.GetVolume(i, TradeSide.Bid);
double askPrice = book.GetPrice(i, TradeSide.Ask);
long askVol = book.GetVolume(i, TradeSide.Ask);
}

// Best bid/ask
double bestBid = book.BestBid;
double bestAsk = book.BestOffer;

See Also​