Code: Select all
protected override void StartCalc()
{
var symbolCategory = ESymbolCategory.None;
Enum.TryParse(Category, true, out symbolCategory);
var dataRequestRange = new DataRequest
{
RequestType = DataRequestType.BarsBack,
Count = Bars.FullSymbolData.Count,
From = new DateTime(1901, 1, 1),
To = Bars.LastBarTime,
ToAlwaysIsNow = true
};
var request = Bars.Request;
request.Subscribe2RT = false;
request.Range = dataRequestRange;
request.TimeZone = RequestTimeZone.Local;
request.Exchange = Exchange;
request.Category = symbolCategory;
request.Symbol = Symbol;
var asyncDataRequest = DataLoader.BeginLoadData(request, OnData, null);
while (!asyncDataRequest.IsCompleted || !IsDataLoaded)
{
Thread.Sleep(100);
}
}
2. I set the DataRequest.ToAlwaysIsNow property to true and set the DataRequest.To property to new DateTime(1901, 1, 1). I expected that the ToAlwaysNow property would override any date in the To property field, but instead it returned no results. Is this a bug, or does ToAlwaysNow work differently than I stated?
3. The Dataloader.BeginLoadData is an async call, so it it highly possible that CalcBar() will fire before your finished receiving the callback or processed the results. I added thread blocking code, but this should also be articulated in your documentation. MC.NET is on the 4.0 framework so this could be refactored into the new Async / Await format and simplify the model as to avert this potential issue. Unless of course you have a different model in mind to manage this process?
Thanks for your replies.