I have a problem with multiple timeframes where a code which was running fine previously is giving errors now.
I am running the code on 60 Minutes (primary) and trying to load Daily bars in the data (loaded in in the State.Configure).
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"My Strategy 1";
Name = "MyStrategy1";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
IsSuspendedWhileInactive = true;
Type = @"C0";
SmaParam = 10;
AtrParam = 10;
Multiplier = 0.7;
LagParam = 5;
AddPlot(Brushes.Orange, "MyLine1");
AddPlot(Brushes.Orange, "MyLine2");
AddPlot(Brushes.Orange, "MyLine3");
}
else if (State == State.Configure)
{
Print("Reached State.Configure");
AddDataSeries(Data.BarsPeriodType.Day, 1);
}
else if (State == State.DataLoaded)
{
Print("Reached State.DataLoaded");
dlyStd = StDev(Inputs[1], 50); // uses the Daily Bars
atr1 = AtrLine(AtrParam); // uses the 60 minute bar
upper = new Series<double>(this, MaximumBarsLookBack.Infinite);
lower = new Series<double>(this, MaximumBarsLookBack.Infinite);
}
}
I get an error when I try to add the indicator to a chart with 60 Minute data on CL 08-2019, with 350 days loaded up:
"'MyStrategy1 tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load CL 08-19 Nymex: 60 Minute"
I don't know why I am getting this error. I am loading the Daily data on the State.Configure, and why is the error saying it "Attempted to load CL 08-19 Nymex: 60 Minute" instead of saying that it attempted to load the Daily data?
Other indicators that don't use multi-timeframes seem to be working alright.
I also noticed that the Print line that prints "Reached State.Configure" is printed twice, whereas the documentation says that "State.Configure" is called only once. https://ninjatrader.com/support/help...tatechange.htm
----
New update: I removed the additional time-frame data, and I still get the error: "'MyStrategy1' tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state. Attempted to load CL 08-19 Nymex: 60 Minute.
With the additional time-frame data removed, the plot is displayed. However, the error does not go away. I think it could be something to do with the new Series<double> code.
Any ideas why this is happening?
Comment