I am able to loop over all windows and check that they are charts, but this seems to only provide me with the charts on active tabs.
Is there a way to also loop over charts on background tabs?
This is what I have so far:
foreach (var window in NinjaTrader.Core.Globals.AllWindows)
{
// Check if the found window is a Chart window, if not continue looking.
if (!(window is NinjaTrader.Gui.Chart.Chart))
continue;
window.Dispatcher.Invoke(new Action(() =>
{
// Try to cast as a Chart, if it fails it will be null.
var foundChart = window as NinjaTrader.Gui.Chart.Chart;
// Make sure we found a chart.
if (foundChart == null)
return;
if (foundChart.ActiveChartControl != null)
{
foreach (var indicator in foundChart.ActiveChartControl.Indicators)
{
// Check for MySpecificIndicator.
if (indicator is NinjaTrader.NinjaScript.Indicators.MySpecificIndicator)
{
if (foundChart.ActiveChartControl.Instrument != null)
{
// Found a chart with MySpecificIndicator.
result.Add(foundChart.ActiveChartControl.Instrument.MasterInstrument.Name);
}
}
}
}
}));
}

Comment