AddDataSeries() never works for me. I first noticed when I tried to put indicators on the chart that were supposed to be using the added data and they displayed nothing. Example:
else if (State == State.Configure)
{AddDataSeries(BarsPeriodType.Minute, 1);
AddDataSeries(BarsPeriodType.Minute, 5);
AddDataSeries(BarsPeriodType.Day, 1);}
else if (State == State.DataLoaded)
{AHLC1 = AverageHighLowChannel(BarsArray[0], SmoothingPeriod, SwingPeriod);
AddChartIndicator(AHLC1);
AHLC2 = AverageHighLowChannel(BarsArray[1], SmoothingPeriod, SwingPeriod);
AddChartIndicator(AHLC2);
AHLC3 = AverageHighLowChannel(BarsArray[2], SmoothingPeriod, SwingPeriod);
AddChartIndicator(AHLC3);}
This only plots the indicators linked to BarsArray[0]. It seems as though the data is not getting passed through on the added data types and I cant figure out why.
Currently I am working on trying to reference a 7 day ATR but I get only zeroes for all the values. Code excerpt:
else if (State == State.Configure)
{AddDataSeries(null, new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 }, 10, null, true);}
else if (State == State.DataLoaded)
{Print("Secondary series: " + BarsArray[1].Instrument.FullName + BarsArray[1].BarsPeriod + " - Bars loaded: " + BarsArray[1].Count);
CurrentDayHL = CurrentDayOHL(BarsArray[1]);
protected override void OnBarUpdate()
{double sum = 0;
for (int i = 1; i < 8; i++) {sum += CurrentDayHL.CurrentHigh[i] - CurrentDayHL.CurrentLow[i];}
double ATR = Math.Round(sum / 7, 2);
double UpRange = CurrentDayHL.CurrentHigh[1] - CurrentDayHL.CurrentOpen[1];
double DownRange = CurrentDayHL.CurrentOpen[1] - CurrentDayHL.CurrentLow[1];
bool OverBought = UpRange > ATR * .55;
bool OverSold = DownRange > ATR * .55;
if (CurrentBar > LastBar)
{Print("---------ATR & Range Values----------");
Print("Yesterday's High = " + CurrentDayHL.CurrentHigh[1]);
Print("Yesterday's Low = " + CurrentDayHL.CurrentLow[1]);
Print("ATR = " + ATR);
Print("UpRange = " + UpRange);
Print("DownRange = " + DownRange);
Print("OverBought = " + OverBought);
Print("OverSold = " + OverSold);
LastBar = CurrentBar;}}
Results in Output Window:
Strategy Updated: 07/01/2026
Secondary series: MNQ SEP26 - Bars loaded: 10
Currency Per Tick: 0.5
Last Rpnl: -52.5
Profit Lock Increment: 150
Max loss locked at = -150
Total Commissions: 0
Enabling NinjaScript strategy ‘Sniper4/371385366’ : On starting a real-time strategy - StartBehavior=AdoptAccountPosition EntryHandling=All entries EntriesPerDirection=20 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=False SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=60 CancelEntriesOnStrategyDisable=True CancelExitsOnStrategyDisable=False Calculate=On price change IsUnmanaged=False MaxRestarts=4 in 5 minutes
---------ATR & Range Values----------
Yesterday’s High = 0
Yesterday’s Low = 0
ATR = 0
UpRange = 0
DownRange = 0
OverBought = False
OverSold = False
Can anyone help please? what do I need to do to make the data pass thorough correctly? I’ve referenced the AddDataSeries() help guide on NT website, and another thread here helped me to use the full syntax (second example) instead of basic syntax like in the first example, but it still doesn’t work.