I have created an indicator and I am using the bar request to get some data.
Here I am trying to get daily data on the SPY.
Here is part of my code :
requestDailyBestVolume = new BarsRequest(Instrument.GetInstrument("SPY", DateTime.Now.AddDays(-25), DateTime.Now);
// Parametrize your request.
requestDailyBestVolume.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 };
requestDailyBestVolume.TradingHours = TradingHours.Get("CME US Index Future RTH");
requestDailyBestVolume.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
{
if (errorCode != ErrorCode.NoError)
{
ChartControl.Dispatcher.InvokeAsync(new Action(() => {
NinjaTrader.Gui.Tools.NTMessageBoxSimple.Show(Wind ow.GetWindow(ChartControl.OwnerChart as DependencyObject), " Error on requesting bars !", "Alert", MessageBoxButton.OK, MessageBoxImage.Hand);
}));
//System.Windows.Forms.MessageBox.Show(" Error on requesting bars !");
return;
}
Print(" Bars Count : "+bars.Bars.Count);
// Output the bars we requested. Note: The last returned bar may be a currently in-progress bar
for (int i = 0; i < bars.Bars.Count; i++)
{
Print((double)bars.Bars.GetVolume(i));
}
After testing it gets the instrument right as well as the Trading Hour but I get no bars ?
it prints Bars Count : 0 and it doesn't get to my second print statement.
What is wrong ?

Comment