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
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
MultipleMarketMakerboolSupport for multiple market makers
ShowHistoricalDOMboolShow historical DOM visualization
HistoryDepthBarsintNumber of historical bars with DOM data
MarketDepthFilteringModeMarketDepthFilteringModeFiltering mode for DOM display

Volume Display Properties

PropertyTypeDescription
CodeExtremeVolumeboolHighlight extreme volumes
DisplayVolumedoubleDisplay volume threshold
ExtremeVolumedoubleExtreme volume threshold
DisplayVolumePercentageintDisplay volume as percentage
ExtremeVolumePercentageintExtreme volume as percentage
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