API Overview
The MZpack API is a C# framework for building custom indicators and automated trading strategies on NinjaTrader 8. It exposes all public classes of the MZpack library. This gives you programmatic access to the same order flow data, volume profiling, and trade detection that power the MZpack chart indicators — letting you create your own analysis tools and trading algorithms.
What You Can Build
| Use Case | Description |
|---|---|
| Custom indicators | Process order flow data (footprint, delta, volume profile, big trades, DOM) and render custom visualizations on NinjaTrader charts using SharpDX/Direct2D |
| Automated strategies | Build rule-based trading systems using the strategy pipeline — combine signals, filters, and decision trees with built-in position and risk management |
| Data export | Extract indicator data (footprint clusters, volume profiles, trade records, DOM snapshots) to CSV for external analysis or machine learning |
Architecture
The API is organized into three layers:
Core Types — data structures that represent market data at every granularity:
| Type | What It Represents |
|---|---|
| ICandle | OHLCV bar data |
| Tick & ITrade | Individual ticks and trade data |
Indicators API — each chart indicator is accessible through a typed interface:
| Interface | Chart Indicator | Key Data |
|---|---|---|
| IFootprintIndicator | mzFootprint | Footprint bars, clusters, imbalance, absorption, S/R zones |
| IVolumeProfileIndicator | mzVolumeProfile | Volume profiles, POC, Value Area, VWAP, TPO |
| IVolumeDeltaIndicator | mzVolumeDelta | Volume/delta histograms, cumulative delta, icebergs |
| IBigTradeIndicator | mzBigTrade | Filtered trades, iceberg detection, DOM pressure |
| IMarketDepthIndicator | mzMarketDepth | DOM snapshots, liquidity, migration, imbalance |
| IDeltaDivergenceIndicator | mzDeltaDivergence | ZigZag breakpoints, divergence signals |
Strategy Pipeline — components for building trading algorithms:
| Component | Role |
|---|---|
| Action | Signal generation — processes market data and outputs a trading direction |
| Filter | Trade filtering — confirms or rejects signals based on additional conditions |
| Decision Tree | Combines signals and filters using AND/OR/CONJUNCTION logic |
| Entry | Order submission — market, limit, or stop-limit with protective orders |
| Exit | Position closing — stop loss, profit target, and exit signals |
| Trail | Trailing stop — follows price at a configurable distance after activation |
| Risk Management | Daily limits — loss, drawdown, profit, and trade count caps |
For a detailed walkthrough of how these components connect, see Pipeline Overview.
Strategy Indicator Classes
Strategies use their own internal indicator instances rather than chart indicators. Each strategy indicator class wraps the corresponding chart indicator:
| Strategy Class | Chart Indicator | Data |
|---|---|---|
| StrategyFootprintIndicator | mzFootprint | Level 1 |
| StrategyVolumeProfileIndicator | mzVolumeProfile | Level 1 |
| StrategyVolumeDeltaIndicator | mzVolumeDelta | Level 1 |
| StrategyBigTradeIndicator | mzBigTrade | Level 1 |
| StrategyMarketDepthIndicator | mzMarketDepth | Level 2 |
| StrategyDeltaDivergenceIndicator | mzDeltaDivergence | Level 1 |
Strategy indicators are not visible on the chart by default. Use Partially Visible mode to show only the data relevant to validated signals — see Algo Strategy — Partially Visible sample.
Built-in Signals
The API ships with 20+ ready-to-use signals that you can combine in decision trees. A few examples:
| Signal | Source Indicator | Description |
|---|---|---|
| DeltaDivergenceSignal | mzDeltaDivergence | Price/delta divergence at swing points |
| FootprintImbalanceSignal | mzFootprint | Stacked imbalances indicating aggressive one-sided activity |
| FootprintAbsorptionSignal | mzFootprint | Passive absorption at price extremes |
| BigTradeSignal | mzBigTrade | Large trade detection with optional iceberg and sweep filters |
| RelativeToProfileSignal | mzVolumeProfile | Price position relative to VWAP, VAH, or VAL |
| DOMImbalanceSignal | mzMarketDepth | Order book bid/ask imbalance |
Custom signals are created by extending the Signal base class. See Built-in Strategies for examples of how these signals are combined.
Requirements
| Requirement | Specification |
|---|---|
| Platform | NinjaTrader 8.0.27 or later |
| Runtime | .NET Framework 4.8 |
| Language | C# 13 (NinjaTrader v8.1.6 required) |
| IDE | Visual Studio 2022 or NinjaTrader 8 built-in editor |
| License | MZpack Strategies w/ Divergence or MZpack Indicators & Strategies w/ Divergence |
See Prerequisites for the full development environment setup, and Project Setup for creating your first project.
Samples
All samples are included in the MZpack source code wrapped in #if APISAMPLE blocks with XML summary comments.
| Sample | Class | What It Demonstrates |
|---|---|---|
| Advanced Template | AdvancedTemplate | Advanced MZpack strategy template with full indicator setup |
| Biggest Trade Indicator | BiggestTradeIndicator | Custom indicator marking the biggest trade with a rectangle |
| Control Panel | ControlPanel | Control Panel with [ControlPanel] attribute and CreateControlPanelElements() |
| Custom Plots | CustomPlots | Access mzFootprint data, custom plots via StrategyPlotIndicator |
| Data Access — mzFootprint | DataAccess_mzFootprint | Access StrategyFootprintIndicator data |
| Data Access — mzVolumeDelta | DataAccess_mzVolumeDelta | Access StrategyVolumeDeltaIndicator data |
| Data Access — mzVolumeProfile | DataAccess_mzVolumeProfile_MinuteAccuracy | Access StrategyVolumeProfileIndicator with Minute accuracy |
| Export Indicator Values | ExportIndicatorsValues | Export indicator values with Historical/Realtime temporality |
| Fibonacci Retracement Entry | FiboRetracementEntryStrategy | Fibonacci retracement entry strategy |
| Multi-DataSeries Advanced | MultiDataSeriesAdvancedStrategy | Trading on a second data series |
| Multi-DataSeries Strategy | MultiDataSeriesStrategy | Using indicators on different data series |
| Algo Strategy — ATM + TradesCluster | MZpackAlgoStrategy0 | Algo.Strategy with proprietary ATM and TradesClusterSignal |
| Algo Strategy — Patterns + ATM | MZpackAlgoStrategy1 | Patterns with ATM, BigTradeSignal, EMASignal, and DOMImbalanceFilter (Level 2, live/replay) |
| Algo Strategy — Partially Visible | MZpackAlgoStrategy2 | Algo.Strategy with TradesClusterSignal, DOMImbalanceSignal, and Partially Visible mode |
| Algo Strategy — Footprint Imbalance | MZpackAlgoStrategy_Imbalance | Algo.Strategy with FootprintImbalanceSignal |
| Custom Strategy — VWAP/POC | MZpackCustomStrategy0 | StrategyVolumeProfileIndicator with VWAP/POC rules for backtesting (OnBarClose) |
| Custom Strategy — BigTrade + VolumeProfile | MZpackCustomStrategy1 | StrategyBigTradeIndicator with StrategyVolumeProfileIndicator in Custom mode for backtesting |
| Custom Strategy — DOM + Footprint | MZpackCustomStrategy4 | StrategyMarketDepthIndicator with StrategyFootprintIndicator, DOM imbalance/block/pace rules (Level 2, live/replay) |
| Custom Strategy — Liquidity Migration | MZpackCustomStrategy6 | Liquidity migration from StrategyMarketDepthIndicator (1 Tick, live/replay) |
| Technical Indicators | MZpackTechnicalSample0 | Using well-known technical indicators in MZpack strategies |
| Risk Management | RiskManagement | RiskManagement class demo (OnBarClose) |
| Trading Times | TradingTimes | TradingTimes feature (OnBarClose) |
Source Code
The Source Code section provides developer-level walkthroughs of the 4 built-in strategy source files — class structure, indicator wiring, signal implementations, decision tree construction, and data export schemas:
| Strategy | What It Demonstrates |
|---|---|
| Footprint Action | 10 signals, AND/OR tree with mandatory grouping, runtime signal toggle, EMA indicator, per-signal bar filters |
| Ghost Resistance | 3 indicators, AND tree with OR sub-node, signal dependency, limit orders, one-entry-per-bar filter |
| Data Export | Non-trading utility, conditional indicators, per-indicator export schemas, 100+ export fields |
| Drawing Objects Export | Minimal strategy, XML schema loading, ChartObjectDescriptor mappings |