real time data inconsistancy  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
holya
Posts: 40
Joined: 28 Aug 2012
Location: Vancouver, Canada
Has thanked: 8 times
Been thanked: 1 time

real time data inconsistancy

Postby holya » 06 Feb 2014

protected override void StartCalc()
{
InstrumentDataRequest idr = this.Bars.Request;
idr.Resolution = this.Bars.Info.Resolution;
idr.Subscribe2RT = true;

DataRequest range = new DataRequest();
range.RequestType = DataRequestType.BarsBack;
range.Count = this.Bars.FullSymbolData.Count;
range.To = this.Bars.LastBarTime;
idr.Range = range;

this.newAnalyzer = new NewAnalyzer();

IDataLoaderResult res = this.DataLoader.BeginLoadData(idr, result =>
{
if (result.Event == DataLoadedEvent.History)
{
this.newAnalyzer.AddHistoricalBarList(result.Data.ToList());
this.downloadCompleted = true;
this.iccdr.ReDraw();
}
else if (result.Event == DataLoadedEvent.RTNewBar)
{
this.newAnalyzer.AddBar((Bar)(result.RTData));
this.iccdr.ReDraw();
}
else if (result.Event == DataLoadedEvent.RTUpdateLastBar)
{
this.newAnalyzer.UpdateBar((Bar)(result.RTData));

this.iccdr.ReDraw();
}
}, null);

#region toolbar construction
this.initToolbar();
#endregion
}

protected override void CalcBar()
{

}

When this code is run for the first time everything works accordingly, But when another symbol
is clicked the "else if (result.Event == DataLoadedEvent.RTUpdateLastBar)" keeps running with the previous data, what ever that might be!!

Can you explain why? T

Thank you.

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: real time data inconsistancy

Postby Henry MultiСharts » 06 Feb 2014

Hello holya,

Please provide more details.
What exact version and build number of MultiCharts are you running? (in MultiCharts go to Help tab-> About).
What do you mean by "But when another symbol is clicked" ?

holya
Posts: 40
Joined: 28 Aug 2012
Location: Vancouver, Canada
Has thanked: 8 times
Been thanked: 1 time

Re: real time data inconsistancy

Postby holya » 06 Feb 2014

I have the latest version (8.8). I have numerous symbols on my WatchList where I can click on any of them to run my indicators (obviously!). And when I click on any other symbol the
"else if (result.Event == DataLoadedEvent.RTUpdateLastBar)
{
this.newAnalyzer.UpdateBar((Bar)(result.RTData));

this.iccdr.ReDraw();
}"

block gets run with previous data!

Is this explanation clear enough?

Thank you

Hamid Olya

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: real time data inconsistancy

Postby Henry MultiСharts » 07 Feb 2014

Hamid, you need to unsubscribe from the realtime data you were subcribed to in the code.
If you do not unsubscribe in the code then you will receive realtime data for each instrument you have subscribed.

holya
Posts: 40
Joined: 28 Aug 2012
Location: Vancouver, Canada
Has thanked: 8 times
Been thanked: 1 time

Re: real time data inconsistancy

Postby holya » 07 Feb 2014

How do I "Unsubscribe"? on what object?

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: real time data inconsistancy

Postby Henry MultiСharts » 07 Feb 2014

To cancel data downloading the void EndLoadData(IDataLoaderResult Result) method should be called. The Result of BeginLoadData call should be put into the argument as an attribute.

holya
Posts: 40
Joined: 28 Aug 2012
Location: Vancouver, Canada
Has thanked: 8 times
Been thanked: 1 time

Re: real time data inconsistancy

Postby holya » 07 Feb 2014

ok i still don't know where to call EndLoadData. Can you please help?

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: real time data inconsistancy

Postby Henry MultiСharts » 07 Feb 2014

A sample code that subscribes to realtime data and outputs the realtime bar values in Output tab of PLEditor window then unsubscribes from realtime data can be found here 

holya
Posts: 40
Joined: 28 Aug 2012
Location: Vancouver, Canada
Has thanked: 8 times
Been thanked: 1 time

Re: real time data inconsistancy  [SOLVED]

Postby holya » 09 Feb 2014

The answer lied within overriding the StopCalc() virtual method, where we can do cleaning up.

Thank you.


Return to “MultiCharts .NET”