Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

button position in main menu

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

    button position in main menu

    Hi , I am using below code to add buttons in main menu for my custom action. I am also using other tool bars which is showing buttons/icons in main menu. I observed that, my button/icon is not showed in same place consistently. Sometime, it is showing my buttons/icons first and other buttons afterwards in main menu. Some other time, it is showing my button/icons in the last. How to make sure that my buttons/icons are will be showing in same order all the time in main menu ?

    chartWindow.MainMenu.Add(myButton)

    #2
    Hello nandhumca,

    Items will be in the order they are added. Use prints and check the code to see what order the .Add() method is being called.

    To add a menu item to the New menu (I assume you mean the Control Center New menu when you say mainmenu), use the code from the help guide on OnWindowCreated().

    Code:
     // Will be called as a new NTWindow is created. It will be called in the thread of that window
    protected override void OnWindowCreated(Window window)
    {
    // We want to place our add on in the Control Center's menus
    ControlCenter cc = window as ControlCenter;
    if (cc == null)
    return;
    
    /* Determine we want to place our add on in the Control Center's "New" menu
    Other menus can be accessed via the control's Automation ID. For example: toolsMenuItem,
    workspacesMenuItem, connectionsMenuItem, helpMenuItem. */
    existingMenuItem = cc.FindFirst("ControlCenterMenuItemNew") as NTMenuItem;
    if (existingMenuItem == null)
    return;
    
    // 'Header' sets the name of our add on seen in the menu structure
    myMenuItem = new NTMenuItem { Header = "My Menu Item",
    Style = Application.Current.TryFindResource("MainMenuItem" ) as Style };
    
    // Place our add on into the "New" menu
    existingMenuItem.Items.Add(myMenuItem);
    
    // Subscribe to the event for when the user presses our add on's menu item
    myMenuItem.Click += OnMenuItemClick;
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am asking about the chart windows menu / tool on the top. I have attached the screenshot and marked the place in blue.

      I am using two different indicators and both are adding buttons in the chart window. On refresh (F5) , the order of group of icons added from these two indicator is keep changing. Since one of the indicator in mine, I am looking for option to add my group of icons at first or last always.
      Last edited by nandhumca; 10-04-2021, 12:11 AM.

      Comment


        #4
        Hello nandhumca,

        It is possible to add custom menus to a chart toolbar by modifying the WPF in an indicator or strategy.

        Below is a link to an example.
        https://ninjatrader.com/support/foru...07#post1124507

        The order of WPF objects are in the order they are added.
        However, you can use .Insert() with collection objects to insert items at a specific index.
        Last edited by NinjaTrader_ChelseaB; 10-03-2021, 08:34 PM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          My question is more about how you have added the "ntBarMenu" in ChartWindow.MainMenu. In attached picture, I have highlighted the group of buttons/menu added by three different indicators including yours. Blue one is yours, Red one is mine and the black one is third party. When I refresh the chart (F5), the order of these three group is not consistent. I think based on the order of indicators refreshed, these group order is getting decided. I want my group of my buttons always on either first or last. Click image for larger version

Name:	chartwindow.PNG
Views:	256
Size:	19.9 KB
ID:	1173418

          Comment


            #6
            Hello nandhumca,

            The indicators may load in a different order.

            Use .Insert() to insert items at a specific index either first or last in State.Realtime.

            If you are asking how to control the order the indicators load and trigger state events, this will not be possible.
            Last edited by NinjaTrader_ChelseaB; 10-03-2021, 09:20 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            571 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 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
            548 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            548 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X