Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to programmatically open a BarsDialog?

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

    How to programmatically open a BarsDialog?

    Hi,

    When programmatically creating and showing a BarsDialog in an add-on, the resulting BarsDialog does not allow selection of any instrument.

    Code:
                // method #1
                var barsDialog1 = new BarsDialog();
                var barsDialog1Result = barsDialog1.ShowDialog();
    
                // method #2
                var barsProperties2 = new BarsProperties();
                var barsDialog2 = new BarsDialog(barsProperties2);
                var barsDialog2Result = barsDialog2.ShowDialog();​
    Click image for larger version  Name:	image.png Views:	0 Size:	17.4 KB ID:	1270682

    What additional properties do I need to set on the BarsDialog for this to work?

    #2
    Hello tcdouglas,

    Unfortunately, this is not supported by NinjaTrader to do, and I would not be able to provide guidance on this.

    This thread will remain open for any community members that would like to provide insight and unsupported code.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      tcdouglas Have you looked at the available properties within the BarsProperties object? You may want to try setting some of those before you fire off the BarsDialog? YMMV.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        jeronymite yes, thank you for your suggestion. Unfortunately there's a large number of properties on BarsProperties and trying to find what needs pre-populating via trial and error has yielded no success.

        Here's an example:

        Code:
        var barsProperties = new BarsProperties
        {
            Instrument = SelectedInstrument.FullName,
            BarsPeriod = (BarsPeriod)SelectedInterval.Clone(),
            IsPrimarySeries = true
        };
         
        var barsDialog = new BarsDialog(barsProperties);
        
        if (barsDialog.ShowDialog() == true)
        {
            ;
        }


        If only NT support could tell me how they do it!

        Comment


          #5
          tcdouglas Yes, it can be frustrating. May I ask why you want to create a BarsDialog? Is it a necessary part of what you want to do? Is the aim to establish the BarsProperties so you can create a new chart? Or are you trying to modify an existing chart? Is the dialog itself important or only the outcome?

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            OK, after much determination and debugging I've finally found the missing 'magic' to make this work: You must simply set the DataContext of the BarsDialog to ChartObjectCollection<BarsProperties> instance. You can then programmatically create a chart window with the populated ChartObjectCollection<BarsProperties> instance:

            Code:
            private void MyWindow4MenuItemOnClick(object sender, RoutedEventArgs e)
            {
                Globals.RandomDispatcher.BeginInvoke(new Action(() =>
                {
                    var barsPropertiesCollection = new ChartObjectCollection<BarsProperties>();
                    var barsDialog = new BarsDialog { DataContext = barsPropertiesCollection }; // must set the DataContext to a ChartObjectCollection<BarsProperties>
                    var barsDialogResult = barsDialog.ShowDialog();
            
                    if (barsDialogResult == true)
                    {
                        var chartWindow = new Chart(barsPropertiesCollection);
                        chartWindow.Show();
                    }
                }));
            }

            jeronymite You ask why I want to do this: I'm developing a completely different chart window and/or customising the existing NT chart window.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            592 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            554 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X