Is there a supported way in NinjaTrader 8 to “embed” indicators that depend on one or more volumetric data series (e.g. 8‑tick and 1‑tick) in addition to the primary series, so that:
- The indicator itself can correctly read and process its own internal series (vol8, vol1).
- The strategy can access and react to the indicator’s public variables (for example, BarsAgoAbsorptionLong[0], HasBullishImbalance, etc.) on each OnBarUpdate.
In other words, how can I achieve reliable, two‑way communication between a strategy and indicators without triggering NullReferenceException in OnStateChange or IndexOutOfRangeException in OnBarUpdate?
I’d appreciate any guidance or examples that show the correct pattern for using AddDataSeries and AddVolumetric together with skipAddSeries, and how to reliably expose an indicator’s calculated series to the parent strategy.
indicator:
else if (State == State.Configure)
{
try
{
if (!SkipAddSeries)
{
Print("Sumando Barra Volumetrica en indicador Poc En Mecha Estrategia trabaja con la Data del indicador ");
AddVolumetric(
Instrument.FullName,
BarsPeriod.BarsPeriodType,
BarsPeriod.Value,
VolumetricDeltaType.BidAsk,
TicksPerLevel,
(int)SizeFilter,
string.Empty,
true);
}
}
catch (Exception ex)
{
Print($“*** ERROR en {GetType().Name}.OnStateChange(State.Configure) ***”);
Print(ex.ToString());
}
}
Strategies:
else if (State == State.Configure)
{
// 1) Serie primaria (ej. 1 min convencional)
// 2) Volumétrico para SessionDeltaExtremes y PocEnMecha
AddVolumetric(Instrument.FullName, BarsPeriod.BarsPeriodType, BarsPeriod.Value, VolumetricDeltaType.BidAsk,TicksPerLevelVol8, (int)SizeFilterVol8, string.Empty, true);
// AddDataSeries(BarsPeriodType.Volumetric, TicksPerLevelVol8, (int)SizeFilterVol8);
// 3) Volumétrico para LineasDeImbalance
AddVolumetric(Instrument.FullName, BarsPeriod.BarsPeriodType, BarsPeriod.Value, VolumetricDeltaType.BidAsk,TicksPerLevelVol1, (int)SizeFilterVol1, string.Empty, true);
// AddDataSeries(BarsPeriodType.Volumetric, TicksPerLevelVol1, (int)SizeFilterVol1);
// Instancia indicadores sobre la serie adecuada
sde = SessionDeltaExtremes(
BarsArray[1],
RangoMinimoDelta,
PeriodoDePromedio,
MultiplicadorDeMecha,
RatioMinimoMechaCuerpo,
PorcentajeMinimoDeConfirmacion,
PorcentajeMaximoMechaOpuesta,
TicksPerLevelVol8,
SizeFilterVol8,
MarkerOffset,true);
poc = PocEnMecha(BarsArray[1], TicksPerLevelVol8, SizeFilterVol8,true);
li = LineasDeImbalance(
BarsArray[2],
RelacionImbalance,
MinimoDeltaImbalance,
Brushes.LimeGreen,
Brushes.Red,
LineWidthImbalance,
LineStyleImbalance,true);
atr = ATR(AtrPeriod); // usa serie principal BarsArray[0]
AddChartIndicator(atr);
AddChartIndicator(sde);
AddChartIndicator(poc);
AddChartIndicator(li);
}