Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need a way to loop over all charts

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need a way to loop over all charts

    I am trying to loop over all open charts and discover ones running a specific indicator.

    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:
    Code:
                    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);
                                        }
                                    }
                                }
                            }
                        }));
                    }

    #2
    Hello gambcl,

    There would not be a supported or documented way of getting indicators from all charts from inactive tabs.

    This may or may not be possible using unsupported custom c#.

    The example linked below uses unsupported code to list chart indicators you may find helpful.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea, I tried the attached code, but it also only loops over charts on active tabs.

      I'll look for another way.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      89 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      143 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      83 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      257 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      334 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X