Dataloader Question  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
FistPeso
Posts: 16
Joined: 01 Sep 2013
Has thanked: 3 times
Been thanked: 8 times

Dataloader Question  [SOLVED]

Postby FistPeso » 02 Sep 2013

I ran into a few issues with Dataloader that are either a bug or I have an improper understanding of their usage. I am using the current 64 Bit version of MC.NET.

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);
}
}
1. When establishing an InstrumentDataRequest by referencing Bars.Request, the To and From properties are not available from Bars.Request. The workaround is easy, but this is either a bug or the documentation should articulate this point.

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.

FistPeso
Posts: 16
Joined: 01 Sep 2013
Has thanked: 3 times
Been thanked: 8 times

Re: Dataloader Bugs/issues

Postby FistPeso » 05 Sep 2013

DataRequest.ToAlwaysIsNow only applies to the time component of the DateTime property. Support indicated that they will add the async/await model as an enhancement request.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Dataloader Question

Postby Henry MultiСharts » 10 Sep 2013

1. When establishing an InstrumentDataRequest by referencing Bars.Request, the To and From properties are not available from Bars.Request. The workaround is easy, but this is either a bug or the documentation should articulate this point.
We have ensured that these properties are available in MultiCharts .NET64 Version 8.7 Release (Build 7689). Please attach the code you are having problem with.
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?
This issue has been confirmed. It will fixed in the next version of MultiCharts .Net
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?
The method you have decided to use is possible, but we still recommend to use sleeps (Thread.Sleep(100);). Waiting can also be implemented with the help of events. Please check the attached code.
Attachments
Test_DataLoaderWaitingLoading.pln
(1.61 KiB) Downloaded 543 times

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Dataloader Question

Postby MidKnight » 08 Sep 2014

From the example, it is not clear to me why you would use an array of WaitHandles and call WaitAny() rather than just a single WaitHandle and call WaitOne() ?

Also, would it not be prudent to have a timeout mechanism in place?

Perhaps you could clarify for us. Thank you.


Return to “MultiCharts .NET”