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.
Can I access the DOM for several instruments in same script?
Can I access the DOM for several instruments in same script?
- 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
- 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
Hello mt99,
Here is how to do that:
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);
}
}