I want to understand what I need to do to manage values across 3 time frames. I'm using a 5 min, a 15 min, and a daily chart. All I need is to print the values of 2 items (1) the price of each time frame and (b) the value of a SMA(14) for each of them. However, I always get an index error. I have gone through the NinjaTrader documentation and I can get it to work on Price but not on the indicator. Hopefully someone can help me. Thanks in advance!
Here is my code:
if (State == State.Configure)
{
AddDataSeries(BarsPeriodType.Minute, 15);
AddDataSeries(BarsPeriodType.Day, 1);
}
else if (State == State.DataLoaded)
{
myEMA9_15Min = EMA(BarsArray[1], 9);
myEMA9_Daily = EMA(BarsArray[2], 9);
}
protected override void OnBarUpdate()
{
double My5minClose=0;
double MyDailyClose=0;
double My15minClose=0;
double My5minEMA9 = 0;
double My15minEMA9 = 0;
double MyDailyEMA9 = 0;
if (CurrentBars[0] < 1 || CurrentBars[1] <= 1 || CurrentBars[2] <1)
return;
if (BarsInProgress == 2 )
{
MyDailyEMA9 = myEMA9_Daily[1];
MyDailyClose = Close[1];
}
if (BarsInProgress == 1 )
{
My15minEMA9 = myEMA9_15Min[1];
My15minClose = Close[1];
}
if (BarsInProgress == 0 )
{
My5minClose = Close[0];
My5minEMA9 = EMA(Close, 50)[0];
Print("My5minClose: " + My5minClose + " | My15minClose: " + My15minClose + " | MyDailyClose: " + MyDailyClose + " | My5minEMA9: " + My5minEMA9 + " | My15minEMA9: " + My15minEMA9 + " | MyDailyEMA9: " + MyDailyEMA9);
}
}

Comment