Can I access the DOM for several instruments in same script?

Questions about MultiCharts .NET and user contributed studies.
mt99
Posts: 18
Joined: 24 Mar 2014
Has thanked: 1 time
Been thanked: 1 time

Can I access the DOM for several instruments in same script?

Postby mt99 » 16 Apr 2014

Hi,

I have been trying to figure out how to access the DOM for more than one instrument (by using Bars.DOM...) from the same script.

I have tried BarsOfData(x) but although I attached the signal to a chart with two instruments on (see picture attached), and MaxDataStream is showing as 2, as I'd expect, the only call that returns a usable DOM is BarsOfData(1), which is for the primary instrument, not the secondary one, as I would have expected. BarsOfData(2) breaks with an exception "Error in the application" and BarsOfData(0) breaks with "Data stream with number -1 doesn't exist".

How can I access the DOM of the secondary (and tertiary etc etc) instrument on the chart that the study is attached to?

Thank you.
Attachments
MC_chart_with_two_instruments.png
Chart to which the signal is attached, showing that it has two distinct instruments on it.
(84.98 KiB) Downloaded 367 times

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

Re: Can I access the DOM for several instruments in same scr

Postby Henry MultiСharts » 17 Apr 2014

Hello mt99,

Here is how to do that:

Code: Select all

protected override void CalcBar()
{
IDOMData _dd = BarsOfData(2).DOM;
if(_dd != null)
{
if(_dd.Ask != null)
if(_dd.Ask.Length > 0)
plot1.Set(BarsOfData(2).DOM.Ask[0].Price);
}
}


Return to “MultiCharts .NET”