View Full Version : "Index was out of range...".
kcsystemtrader
05-28-2009, 07:46 AM
I'm adding a daily bars object,
Add(Symbol, PeriodType.Day, 1); //BarsInProgress ==4
to my strategy, and then trying to pull yesterdays closing price on a different time frame using:
yestClose = Closes[4][1]
and I get the index out of range error. I've tried:
if(CurrentBar < 1)
return;
and still get the error. Any ideas why that would be happening? Thanks,
kc
NinjaTrader_Bertrand
05-28-2009, 07:57 AM
Does your connection / data provider support historical daily data kcsystemtrader?
You can check it here - http://www.ninjatrader-support.com/HelpGuideV6/HistoricalData.html
kcsystemtrader
05-28-2009, 08:07 AM
Does your connection / data provider support historical daily data kcsystemtrader?
You can check it here - http://www.ninjatrader-support.com/HelpGuideV6/HistoricalData.html
yes, it is IB, and I've tried on my live account as well
NinjaTrader_Bertrand
05-28-2009, 08:13 AM
Hmm, are you sure this is BarsInProgress 4? Keep in mind the index for those starts at 0.
kcsystemtrader
05-28-2009, 10:09 AM
Hmm, are you sure this is BarsInProgress 4? Keep in mind the index for those starts at 0.
BarsInProgress == 0 is an index
==1 is ticks on the stock I'm trading
==2 is 1 MIN on the stock I'm trading
==3 is 5 MIN on the stock I'm trading
==4 is Day on the stock I'm trading
on BarsInProgress == 1, every tick, I wait for ten 10 ticks before running any code using:
if(CurrentBar < 10)
return;
then Closes[4][1] runs and I get the error in the log saying the index was out of range. Meanwhile I have a daily chart loaded that looks fine and the historical data has definitely been downloaded and should be accessible
NinjaTrader_Bertrand
05-28-2009, 10:46 AM
kcsystemtrader, please check into this sample and the sequential order in which the bars objects are added - http://www.ninjatrader-support2.com/vb/showthread.php?t=6652
Please add the slower charts first and then progress to the fastest one you use.