This is a sample from the output window:
datetime: 22/11/2016 12:00:00 AM
Primary Series: Time: 5/12/2016 5:01:01 AM Open: 2181.25 High: 2181.25 Low: 2181.25 Close: 2181.25 Volume: 0
Primary Series: Time: 5/12/2016 5:01:02 AM Open: 2181.5 High: 2181.5 Low: 2181.5 Close: 2181.5 Volume: 0
Primary Series: Time: 5/12/2016 5:01:03 AM Open: 2181.75 High: 2181.75 Low: 2181.75 Close: 2181.75 Volume: 0
Primary Series: Time: 5/12/2016 5:01:09 AM Open: 2182 High: 2182 Low: 2182 Close: 2182 Volume: 0
Primary Series: Time: 5/12/2016 5:01:13 AM Open: 2182.25 High: 2182.25 Low: 2182.25 Close: 2182.25 Volume: 0
Primary Series: Time: 5/12/2016 5:01:32 AM Open: 2182 High: 2182 Low: 2182 Close: 2182 Volume: 0
public BarsRequest RequestPrimaryBars(DateTime datetime)
{
Print("datetime: " + datetime);
primaryBarsRequest = new BarsRequest(Cbi.Instrument.GetInstrument(Instrument.FullName), datetime, datetime.AddDays(1));
// Parametrize your request.
primaryBarsRequest.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Second, Value = 1 };
primaryBarsRequest.TradingHours = TradingHours.Get("Default 24 x 7");
// Request the bars
primaryBarsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
{
if (errorCode != ErrorCode.NoError)
{
// Handle any errors in requesting bars here
NinjaTrader.Code.Output.Process(string.Format("Error on requesting bars: {0}, {1}",
errorCode, errorMessage), PrintTo.OutputTab1);
return;
}
// 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++)
{
// Output the bars
NinjaTrader.Code.Output.Process(string.Format("Primary Series: Time: {0} Open: {1} High: {2} Low: {3} Close: {4} Volume: {5}",
bars.Bars.GetTime(i),
bars.Bars.GetOpen(i),
bars.Bars.GetHigh(i),
bars.Bars.GetLow(i),
bars.Bars.GetClose(i),
bars.Bars.GetVolume(i)), PrintTo.OutputTab1);
}
}));
return primaryBarsRequest;
}

Comment