Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I know when the instrument is selected from the MainMenu?

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

    How can I know when the instrument is selected from the MainMenu?

    How can I know when the instrument is selected from the MainMenu?
    The OnInstrumentChanged method is not called.
    Like the example we have here:



    // This method is fired when our instrument selector changes instruments
    private void OnInstrumentChanged(object sender, EventArgs e)
    {
    Instrument = sender as Cbi.Instrument;
    }

    If you can give an working example, it would help a lot.
    Tks!

    #2
    Hello cassiano_sanches,

    Thanks for your post.

    From the window, you will have to find the InstrumentSelector from Automation ID. The Windows Kits inspect tool can be used to find Automation IDs. A publicly available link regarding the Windows Kits inspect tool can be found below.

    https://docs.microsoft.com/en-us/win...nspect-objects

    Please see the attached example which demonstrates finding the Instrument Selector. Code is implemented in an indicator. If you need to loop through all open windows, you could do something like the following:

    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;
    }
    We look forward to assisting.
    Attached Files

    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