Hi there,
Is there anyway to get a list of the data series objects that are on a chart?
With thanks in advance,
MK
Finding a list of data series objects
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Finding a list of data series objects
Hi there Henry,
I don't see how IInstrument helps me - maybe you can be more specific. I want a list of all the data series objects on a chart so I can iterate through them all. There may be any number of streams on the chart so hardcoding the data stream count is not practical.
All my best,
MK
I don't see how IInstrument helps me - maybe you can be more specific. I want a list of all the data series objects on a chart so I can iterate through them all. There may be any number of streams on the chart so hardcoding the data stream count is not practical.
All my best,
MK
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Finding a list of data series objects
Hello MidKnight,
With MaxDataStream you can check the maximum number of the data series on the chart.
With CStudyControl.IsExist you can check what dataseries are present on the chart and what are missing.
Using BarsOfData you can get access to the data of the certain dataseries. With IInstrument you can get all of the information regarding this data series.
With MaxDataStream you can check the maximum number of the data series on the chart.
With CStudyControl.IsExist you can check what dataseries are present on the chart and what are missing.
Using BarsOfData you can get access to the data of the certain dataseries. With IInstrument you can get all of the information regarding this data series.
Re: Finding a list of data series objects
Thanks for the reply Henry. I had seen the MaxDataStreams property but the help says:
Thanks again for the reply. You teach me a lot.
With kind regards,
MK
But you are saying it is telling you the total number of data streams on the chart. That is why I was confused. I'll do some testing on my own with this property, but I think the help file isn't clear and/or the name of the property is ambiguous. DataStreamCount would have been a much clearer name to me.Read-only property. Maximum available number of datastreams allowed on the chart.
Thanks again for the reply. You teach me a lot.
With kind regards,
MK
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Finding a list of data series objects
Hello MidKnight,
Thank you. We'll fix the description.
The correct one is:
IStudy.MaxDataStream Property
Read-only property. The maximum index number of datastreams present on the chart.
Thank you. We'll fix the description.
The correct one is:
IStudy.MaxDataStream Property
Read-only property. The maximum index number of datastreams present on the chart.
Re: Finding a list of data series objects
I noticed there is an inconsistency for MaxDataStream property in Portfolio Manager and when Charting.
In Portfolio Manager, MaxDataStream is always 10 while in Charting, MaxDataStream is the data number of the last data stream on the chart.
This is probably a bug in MultiCharts that needs to be fixed. For now, I'm using the following code to work around this issue:
In Portfolio Manager, MaxDataStream is always 10 while in Charting, MaxDataStream is the data number of the last data stream on the chart.
This is probably a bug in MultiCharts that needs to be fixed. For now, I'm using the following code to work around this issue:
Code: Select all
private int? _dataStreamCount;
public int DataStreamCount
{
get
{
if (_dataStreamCount == null)
{
if (Environment.ApplicationCode == EApplicationCode.Portfolio)
{
// in Portfolio Manager, MaxDataStream is always 10
_dataStreamCount = 0;
for (int i = 1; i <= MaxDataStream; i++)
{
if (!IsExist(i))
{
break;
}
_dataStreamCount++;
}
}
else
{
// in Charting, MaxDataStream is the data number of the last data stream on chart
_dataStreamCount = MaxDataStream;
}
}
return _dataStreamCount.Value;
}
}
- Svetlana MultiCharts
- Posts: 645
- Joined: 19 Oct 2017
- Has thanked: 3 times
- Been thanked: 163 times
Re: Finding a list of data series objects
Hello, orad,
This behaviour is expected. A study cannot know how many data series are accessible, unless it tries to access each of them. One needs to take into account the number of data series required for the study operation beforehand while developing this study. Unfortunately, there is not any universal way.
This behaviour is expected. A study cannot know how many data series are accessible, unless it tries to access each of them. One needs to take into account the number of data series required for the study operation beforehand while developing this study. Unfortunately, there is not any universal way.