Hi everyone!
I've been working at this for a couple weeks now and can't seem to figure out what the issue is. I know it is something to do with the additional data series I am trying to incorporate into my strategy, I'm just not sure how to fix the issue, or why it's happening on bar 1771. I've tried looking at Ninjatraders Multi Time Frame page (https://ninjatrader.com/support/help...dataseries.htm), but the haven't been able to find a solution in there. I've been searching through these forums too and haven't found anything relating to this problem specifically. I could definitely be wrong about that though.
Bellow is a simplified version of my code, but all of the important pieces are copy and pasted. I'm building it to work with ES futures.
Any help will be greatly appreciated, and I look forward to hearing from some of you!
private Series<double> barOverlap;
private EMA ema;
private SMA sma;
private RSI rsi;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
IsInstantiatedOnEachOptimizationIteration = false;
StartBehavior = StartBehavior.WaitUntilFlat;
Calculate = Calculate.OnEachTick;
EntryHandling = EntryHandling.UniqueEntries;
EntriesPerDirection = 2;
BarsRequiredToTrade = 30;
}
else if (State == State.Configure)
{
AddDataSeries("", new BarsPeriod { BarsPeriodType = BarsPeriodType.Tick, Value = 5000 }, 10, "", true);
AddDataSeries("", new BarsPeriod { BarsPeriodType = BarsPeriodType.Tick, Value = 10000 }, 10, "", true);
AddDataSeries("", new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 }, 10, "", true);
}
else if (State == State.DataLoaded)
{
ema = EMA(20);
rsi = RSI(14, 3);
sma = SMA(240);
AddChartIndicator(ema);
AddChartIndicator(sma);
// Passing in BarsArray[0](Primary Data Series) as an argument results in an empty Series with an identical number of index slots
// Used later on in OnBarUpdate to store % that bar 1 is overlapping with bar 2
barOverlap = new Series<double>(this);
}
}
protected override void OnBarUpdate()
{
// KEEP TO PREVENT INITIAL OUT OF BOUNDS ERRORS
if (CurrentBars[0] <= BarsRequiredToTrade || CurrentBars[1] <= 4 || CurrentBars[2] <= 4 || CurrentBars[3] < 2)
return;
if (BarsInProgress != 0)
return;
if (required conditions are met)
{
enter order
}
Thank you for your time!
Comment