Skip to main content

DrawingObjectsExport

Exports chart drawing objects (arrows, text, dots, regions) as numeric values in CSV format. Each drawing object is matched against a mapping table and converted to a double value.

Namespace: MZpack.NT8.Algo Inheritance: DrawingObjectsExport : GeneralExport

Constructor

new DrawingObjectsExport(MZpackStrategyBase strategy, ExportArgs exportArgs)

The export uses ExportDataSource.Level1, ExportTemporality.Historical, and ExportGranularity.Bar by default.

How It Works

  1. The export scans strategy.DrawObjects for drawing objects at the current time
  2. Only objects with anchors and IsAttachedToNinjaScript = true are included
  3. Each object is passed to ChartObjectDescriptor.GetValue() for mapping
  4. The mapped value is written as a row in the DataSet

The row timestamp is taken from the first anchor of the drawing object.

ChartObjectDescriptor

Defines how drawing objects are filtered and mapped to numeric values.

Properties

PropertyTypeDefaultDescription
ScriptstringnullFilter: only objects drawn by this script (null = any)
TagstringnullFilter: only objects whose tag contains this substring (null = any)
MapList<MapItem>Mapping rules from drawing tool attributes to values

MapItem

Each MapItem matches a drawing object by tool type, text, and/or color, and maps it to a numeric value.

PropertyTypeDefaultDescription
ToolDrawingToolAnyDrawing tool type to match
TextstringnullDisplay text to match (null = any)
ColorstringnullColor name to match (null = any)
ValuedoubleNumeric value returned when matched

The first MapItem that matches wins. If no item matches, double.NaN is returned.

DrawingTool Enum

ValueDescription
AnyMatch any drawing tool type
ArrowDownDown arrow
ArrowUpUp arrow
DiamondDiamond shape
DotDot marker
RegionHighlighted region
SquareSquare marker
TextText annotation
TextFixedFixed-position text
TriangleDownDown triangle
TriangleUpUp triangle

Example

Export all ArrowUp drawing objects with tag "signal" as value 1.0, and ArrowDown as value −1.0:

var chartDesc = new ChartObjectDescriptor
{
Tag = "signal",
Map = new List<ChartObjectDescriptor.MapItem>
{
new ChartObjectDescriptor.MapItem
{
Tool = DrawingTool.ArrowUp,
Value = 1.0
},
new ChartObjectDescriptor.MapItem
{
Tool = DrawingTool.ArrowDown,
Value = -1.0
}
}
};

var args = new ExportArgs
{
FileName = "signals.csv",
IsHeader = true,
IsTime = true
};

var export = new DrawingObjectsExport(strategy, args);

export.DataSet.Schema
.Append(IndValue.Close)
.Append(IndValue.Delta)
.Append("signal", ValueKind.Label, chartDesc);

export.ExportDates(beginTime, endTime);

This produces a CSV with columns: Time, Close, Delta, signal where signal is 1.0 for up arrows, −1.0 for down arrows, and NaN for bars without matching drawing objects.

See Also