Skip to main content

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
}
ValueDescription
HistoricalExport historical bar data after loading
RealtimeExport data as it arrives in real time

ExportDataSource​

ValueDescription
Level1Level 1 (trade/tick) data
Level2Level 2 (market depth) data
CustomCustom data source

ExportGranularity​

ValueDescription
TickOne row per tick
BarOne row per bar
UpdateOne row per update event

ExportMode​

ValueDescription
SaveWrite data to output
LoadRead data from file

ExportArgs​

Configuration object passed to all export constructors.

PropertyTypeDefaultDescription
FileNamestring—Output file name (e.g., "data.csv")
BaseDirectorystringnullRoot directory (null = strategy default \data)
SubDirectorystring—Subdirectory within base
IsHeaderboolfalseInclude column header row
IsTimeboolfalseInclude Time column
IsFilebooltrueWrite to file
IsNinjaScriptOutputboolfalseWrite to NinjaScript Output panel
IsExportWhileCollectingboolfalseStream 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
FlushIntervalMsint0Streaming-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
IsBatchboolfalseCreate numbered batch files
Delimiterchar,Column delimiter
SignedVolumeboolfalsePrefix volumes with sign (+buy, −sell)
Shiftint0Bar 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​

ConstantValueDescription
Export.DELIMITER,Default delimiter
Export.TIME_FORMATyyyy-MM-ddTHH:mm:ss.fffTimestamp format
Export.APPENDtrueAppend mode flag

See Also​