Multi-DataSeries Advanced
Demonstrates trading on a second data series using Algo.Strategy in unmanaged mode. Adds a secondary instrument/timeframe via AddDataSeries and routes trade execution to it.
Source: [INSTALL PATH]/API/Samples/MultiDataSeriesAdvancedStrategy.cs
Class: MultiDataSeriesAdvancedStrategy : MZpackStrategyBase
What It Covers
Algo.StrategywithIsUnmanaged = true(required for multi-dataseries)WorkingDataSeriesIdx = -1to pass all data series to the coreTradingDataSeriesIdx = 1to route entries to the secondary seriesUpDownBarSignalfor simple entry logic
Strategy Setup
protected MZpack.NT8.Algo.Strategy CreateAlgoStrategy()
{
MZpack.NT8.Algo.Strategy strategy = new MZpack.NT8.Algo.Strategy(
@"Multi-DataSeries Advanced", this)
{
IsUnmanaged = Strategy_Instrument_Enable ? true : false,
};
return strategy;
}
Configuration
When the secondary instrument is enabled, WorkingDataSeriesIdx is set to -1 so the core processes all data series, and TradingDataSeriesIdx routes entries to the secondary series:
if (Strategy_Instrument_Enable)
{
WorkingDataSeriesIdx = -1; // Pass all dataseries to the core
AddDataSeries(Strategy_Instrument_Name,
Strategy_Instrument_BarsPeriodType,
Strategy_Instrument_BarsPeriodValue);
TradingDataSeriesIdx = 1; // Route entries to secondary series
}
Entry[] entries = new Entry[EntriesPerDirection];
entries[0] = new Entry(Strategy)
{
Quantity = 1,
SignalName = "MDSA",
StopLossCalculationMode = CalculationMode.Ticks,
StopLossTicks = 10,
ProfitTargetCalculationMode = CalculationMode.Ticks,
ProfitTargetTicks = 20,
};
Pattern entryPattern = new Pattern(Strategy, Logic.And, null, true);
entryPattern.Signals.Root.AddChild(new UpDownBarSignal(Strategy) { Name = "Up/Down" });
Strategy.Initialize(entryPattern, exitPattern, entries);
Configurable Properties
| Property | Default | Description |
|---|---|---|
Strategy_Instrument_Enable | true | Enable secondary instrument |
Strategy_Instrument_Name | "MES 12-24" | Secondary instrument name |
Strategy_Instrument_BarsPeriodType | Minute | Secondary instrument period type |
Strategy_Instrument_BarsPeriodValue | 1 | Secondary instrument period value |
Key Points
IsUnmanaged = trueis mandatory for multi-dataseries strategiesWorkingDataSeriesIdx = -1tells the core to process all data series, not just the primaryTradingDataSeriesIdxsets which data series receives the trade entries
See Also
- MZpackStrategyBase — base class
- Algo.Strategy — strategy framework
- Entry — entry configuration
- Multi-DataSeries Strategy — indicators on multiple data series
- Working with Samples — how to compile samples