When using that constructor, the lowest granularity for intraday requests you can obtain is 1 trading day of data. Meaning, for tick data, it will return at least one full trading day of tick data, even though your fromLocal/toLocal are using a shorter segement. You see multiple calendar days in your output since it starts from the session start based on the .TradingHours you configure (e..g, Default 24/7 would start at 12:00AM Eastern, which may be 10:00PM Mountain the previous day). It is not possible to request just a segment of tick data with that constructor.
If you use the "barsBack" parameter, you can request less data, but it will be barsBack from the current bar, which I don't think meets your purposes.
So as per your edit, you'd just need to loop through the request and filter for the data you need:
private DateTime BeginTime;
private DateTime EndTime;
private void DoRequest()
{
BarsRequest barsRequest = new BarsRequest(Instrument, BeginTime, EndTime);
barsRequest.BarsPeriod = new BarsPeriod {BarsPeriodType = BarsPeriodType.Tick, Value = 1};
barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");
barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((theBars, errorCode, errorMessage) =>
{
Print("BEGIN: " + BeginTime + " END: " + EndTime);
Bars myBars = theBars.Bars;
for (int i = 0; i < myBars.Count; i++)
{
[B] if(myBars.GetTime(i) < BeginTime || myBars.GetTime(i) > EndTime)
continue;[/B]
Print(" " + theBars.Bars.GetTime(i) + " " + theBars.Bars.GetClose(i) + " " + theBars.Bars.GetVolume(i));
}
}));
}


Comment