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

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    22 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Started by guillembm, Yesterday, 11:25 AM
    2 responses
    9 views
    0 likes
    Last Post guillembm  
    Started by junkone, 04-21-2024, 07:17 AM
    9 responses
    70 views
    0 likes
    Last Post jeronymite  
    Started by mgco4you, Yesterday, 09:46 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X