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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X