Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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 geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,288 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Working...
      X