I'm getting this error backtesting a strategy that uses HistoricalData as BarData:
Accessing data bigger than 2000 bars isn't guaranteed during backtest
I suppose the offending statement is the following:
BarData historicalData = GetHistoricalData(
new HistoricalDataRequest(Instruments.Current, Period.Min)) as BarData;
I understand the error/warning but I haven't figured out a way to limit/slice the amount of data to retrieve.
Let me explain what I am trying to accomplish just in case I am not using the proper method:
I need to get the slice of bars between two dates. Put in code, something like this:
public IEnumerable<Bar> GetBars(int minutes, DateTime fromTime, DateTime toTime)
I have found a method to get the historical index from a date:
int fromIndex = historicalData.FindInterval(fromTime)
But I need the HistoricalData object to be created before anyway so it doesn't seem to help much.
Any idea about how to get/slice a segment of the historical data line?