Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can Addon Distinguish Between Two Charts

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

    Can Addon Distinguish Between Two Charts

    If I open two identical charts is there a way for an addon to know which chart is which? Do charts have an ID or some unique identifying parameter that can be queried by an addon to know which chart its working on?

    If not, is there a tag or some user parameter that we can set with an addon to ID the chart when it first opens?

    I don't want to use an indicator to do this and I want to assume that everything about the two charts is identical, same time frame, same instrument, etc, except for this identification parameter.

    Thanks,
    Fred

    #2
    Hello PhineasPhred,

    Thanks for your question.

    We are starting to get into undocumented territory, but you may wish to access ChartControl.OwnerChart.GetHashCode() to get an integer that can be used as an identifier. This can be called from an indicator. If you would like to get a hash code externally, you consider checking the following in a loop through all windows.

    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.InvokeAsync(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;
    
            Print(foundChart.GetHashCode());
    
        }));
    
    }
    We look forward to assisting.

    Comment


      #3
      Hi Jim,

      I actually thought about using GetHashCode() at one time, but wasn't sure if it was guaranteed to be unique for each chart, especially if both charts were the same. I'm assuming from your answer that I can rest assured.

      Thanks for the quick response and help!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X