Data Export Overview
The MZpack data export system provides a composable pipeline for exporting indicator values and chart drawing objects to CSV files or the NinjaScript Output panel.
Namespace: MZpack.NT8.Algo
Two Export Scenarios
1. IndicatorExport — Indicator Values
Exports calculated values from MZpack indicators (footprint metrics, volume profile levels, delta, etc.) to CSV. Each row represents a bar, with columns defined by a DataSchema.
2. DrawingObjectsExport — Chart Drawing Objects
Exports chart annotations (arrows, text, dots, etc.) placed by strategies. Each drawing object is mapped to a numeric value via a ChartObjectDescriptor, enabling signal labeling for analysis or machine learning.
Architecture
Pipeline
├── IndicatorExport (indicator values → CSV)
│ ├── ExportedIndicator (data source)
│ └── DataSet (rows of values)
│ └── DataSchema (column definitions)
│ └── ValueDescriptor[]
│
└── DrawingObjectsExport (drawing objects → CSV)
├── ChartObjectDescriptor (object → value mapping)
└── DataSet
└── DataSchema
Pipeline
Pipeline is the central orchestrator. It chains one or more IndicatorExport instances and drives per-bar export across all of them. Adjacent exports are linked via PipelinePrior / PipelineNext for synchronized processing.
var args = new ExportArgs
{
FileName = "ES_footprint.csv",
IsHeader = true,
IsTime = true
};
var pipeline = new Pipeline(strategy, args);
var fpExport = new IndicatorExport(strategy, fpIndicator,
ExportDataSource.Level1, ExportTemporality.Historical,
ExportGranularity.Bar, args);
fpExport.DataSet.Schema
.Append(IndValue.POC)
.Append(IndValue.Delta)
.Append(IndValue.Volume);
pipeline.Add(true, fpExport);
pipeline.ExportDates(beginTime, endTime);
Enums
ExportTemporality
[Flags]
public enum ExportTemporality
{
Historical = 1,
Realtime = 2
}
| Value | Description |
|---|---|
Historical | Export historical bar data after loading |
Realtime | Export data as it arrives in real time |
ExportDataSource
| Value | Description |
|---|---|
Level1 | Level 1 (trade/tick) data |
Level2 | Level 2 (market depth) data |
Custom | Custom data source |
ExportGranularity
| Value | Description |
|---|---|
Tick | One row per tick |
Bar | One row per bar |
Update | One row per update event |
ExportMode
| Value | Description |
|---|---|
Save | Write data to output |
Load | Read data from file |
ExportArgs
Configuration object passed to all export constructors.
| Property | Type | Default | Description |
|---|---|---|---|
FileName | string | — | Output file name (e.g., "data.csv") |
BaseDirectory | string | null | Root directory (null = strategy default \data) |
SubDirectory | string | — | Subdirectory within base |
IsHeader | bool | false | Include column header row |
IsTime | bool | false | Include Time column |
IsFile | bool | true | Write to file |
IsNinjaScriptOutput | bool | false | Write to NinjaScript Output panel |
IsExportWhileCollecting | bool | false | Stream rows as they are collected. The file is truncated once on the first row and appended thereafter; when false, all rows are written when the export's temporality ends |
FlushIntervalMs | int | 0 | Streaming-writer flush period in milliseconds. 0 flushes every row; raise it for high-rate Level 2 or Update exports to trade visibility latency for throughput |
IsBatch | bool | false | Create numbered batch files |
Delimiter | char | , | Column delimiter |
SignedVolume | bool | false | Prefix volumes with sign (+buy, −sell) |
Shift | int | 0 | Bar shift for exported items |
Streaming a Realtime Export
Set IsExportWhileCollecting only when the consumer needs rows before the strategy stops. The streaming writer stays open with FileShare.ReadWrite, so another process such as Excel can read the CSV while it is being written. IsBatch remains the way to retain prior runs; a normal streaming run replaces its file on the first row.
var args = new ExportArgs
{
FileName = "ES_dom.csv",
IsHeader = true,
IsExportWhileCollecting = true,
FlushIntervalMs = 250 // batch disk flushes for a high-rate DOM export
};
For an export whose Temporality is Historical, rows are produced during the historical load. A Realtime export is the usual case for a file watched while a strategy is running.
Constants
| Constant | Value | Description |
|---|---|---|
Export.DELIMITER | , | Default delimiter |
Export.TIME_FORMAT | yyyy-MM-ddTHH:mm:ss.fff | Timestamp format |
Export.APPEND | true | Append mode flag |
See Also
- DataSchema / DataSet — defining output structure
- ValueDescriptor — column definitions and delegates
- DrawingObjectsExport — exporting chart annotations
- Export Indicators Values sample — complete working example