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

Customizing Chart Trader - NT8

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

    Customizing Chart Trader - NT8

    Hello all,

    My question is related to a request topic from earlier this year: http://ninjatrader.com/support/forum...ad.php?t=75053

    Can you please provide a code snippet that shows how to enumerate the controls on the Chart Trader's main grid (i.e. Buy Mkt, Sell Mkt,... PnL, etc.). For example, something like:

    Code:
    // Find chart trader from parent chart by it's automation id "ChartWindowChartTrader"
    chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader;
    
    // This is the main chart trader grid where the default buttons and controls reside
    mainGrid = chartTrader.FindName("grdMain") as Grid;
    
    if (mainGrid == null)
    {
         Print("mainGrid is null");
         return;
    }
    
    // THIS PIECE OF CODE DOES NOT WORK, AS THERE IS NO NAME PROPERTY
    for ( int ctr=0; ctr < mainGrid.Children.Count; ctr++ )
        Print( mainGrid.Children[ctr].Name );
    Although I realize this is an advanced feature that may not be fully supported, I would like to be able to know what each of the child controls are called -- and from that hopefully what they do as a first step in customizing their behavior.

    Many thanks.

    #2
    Hello D Trader,

    Below are links to an example that demonstrates modifying the Chart Trader area.


    Attached is another example of this.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea_B.

      The example demonstrates how to add new buttons to the Chart Trader panel. How does one reference the existing buttons and controls that are the default? E.g. "Buy Mkt", "Sell Mkt", the PnL display, etc.?

      Comment


        #4
        Hello D Trader,

        May I confirm you have added the ChartTraderModifyExistingButtonsExample indicator to a chart and opened Chart Trader to view the changes?

        Or have you opened the script to review the code?

        Attached is a screenshot showing a chart with the indicator added. Notice the colors of the existing buy market and sell market buttons have changed.

        When clicking a button, the original order is placed but a message appears on the chart.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Apologies, Chelsea. I glanced at the code too quickly and assumed it was the same as previous examples that only added custom buttons to Chart Trader.

          So I see here that the Automation names for the Buy Mkt and Sell Mkt buttons are ChartTraderControlQuickBuyMarketButton and ChartTraderControlQuickSellMarketButton, respectively.

          Can you provide the names of the other Chart Trader controls? The best solution would be to enumerate the full set of controls using a Controls property array, or something similar. Apart from that, it is unlikely anyone could guess the Automation names of the other CT controls.

          What are the names associated with each of the following remaining CT controls, please:
          • Buy Ask - button
          • Sell Ask - button
          • Buy Bid - button
          • Sell Bid- button
          • Rev - button
          • Close - button
          • Instrument - label and dropdown
          • TIF - label and dropdown
          • Account - label and dropdown
          • Order qty - label and dropdown
          • ATM Strategy - label and dropdown
          • A: (Ask) - label and dynamic value displays
          • B: (Bid) - label and dynamic value displays

          Many thanks!

          Comment


            #6
            Hello D Trader,

            I do not have a complete list of the automation ids, but you can find these for any visible objects you need.

            Below is a link to a video that demonstrates how to use the Microsoft Inspect tool to find automation ids of wpf objects in existing programs.
            This video demonstrates where to find the Microsoft Inspect tool from the Windows 8.1 SDK (installed with Visual Studio) and how to use this to find Automation Ids and view the parent child hierarchy.


            (edit)
            A small note, modifying the existing chart window or chart trader area or any other part of the NinjaTrader interface that is not in your own addon window would fall under undocumented.

            Below is a link to the help guide on addons.
            http://ninjatrader.com/support/helpG...-us/add_on.htm
            Last edited by NinjaTrader_ChelseaB; 09-01-2022, 07:38 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thank you. I shall give the Inspect tool a try.

              Comment


                #8
                Hello,

                The ChartTraderModifyExistingButtonsExample_NT8B13 sample has been updated and can be found at:

                Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  ChelseaB. I realize that this is an old thread. I'm using this code to place buttons on ChartTrader. How do I input the value of the Quantity box?

                  Comment


                    #10
                    Hi boreland, thanks for your question.

                    If you need to get the value of the Quantity TextBox, you must get it by the AutomationID. You can get the automation ID of the TextBox using the Inspect.exe tool from Microsoft (comes with Windows 10 SDK).

                    e.g.

                    Code:
                    public class ChartTraderModifyExistingButtonsExample : Indicator
                        {
                    [B]private System.Windows.Controls.TextBox     quantityBox;[/B]
                            private System.Windows.Controls.Button        buyMarketButton;
                            private NinjaTrader.Gui.Chart.ChartTab        chartTab;
                            private System.Windows.Controls.Grid        chartTraderGrid;
                            private NinjaTrader.Gui.Chart.Chart            chartWindow;
                            private Brush                                originalButtonColor;
                            private bool                                panelActive;
                            private System.Windows.Controls.Button        sellMarketButton;
                            private System.Windows.Controls.TabItem        tabItem;
                    
                            protected override void OnStateChange()
                            {
                                if (State == State.SetDefaults)
                                {
                                    Description                    = @"Enter the description for your new custom Indicator here.";
                                    Name                        = "ChartTraderModifyExistingButtonsExample";
                                    Calculate                    = Calculate.OnBarClose;
                                    IsOverlay                    = true;
                                    DisplayInDataBox            = true;
                                    DrawOnPricePanel            = true;
                                    DrawHorizontalGridLines        = true;
                                    DrawVerticalGridLines        = true;
                                    PaintPriceMarkers            = true;
                                    ScaleJustification            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                                    IsSuspendedWhileInactive    = true;
                                }
                                else if (State == State.Historical)
                                {
                                    if (ChartControl != null)
                                    {
                                        ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                                        {
                                            CreateWPFControls();
                                        }));
                                    }
                                }
                                else if (State == State.Terminated)
                                {
                                    if (ChartControl != null)
                                    {
                                        ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                                        {
                                            if (chartWindow != null)
                                                chartWindow.MainTabControl.SelectionChanged -= TabChangedHandler;
                    
                                            HideWPFControls();
                                        }));
                                    }
                                }
                            }
                            protected void BuyMarketButton_Click(object sender, RoutedEventArgs e)
                            {
                                Draw.TextFixed(this, "infobox", "Buy Market Button Clicked", TextPosition.BottomLeft, Brushes.Green, new Gui.Tools.SimpleFont("Arial", 25), Brushes.Transparent, ChartControl.Properties.ChartBackground, 100);
                                // only invalidate the chart so that the text box will appear even if there is no incoming data
                                ChartControl.InvalidateVisual();
                            }
                    
                            protected void CreateWPFControls()
                            {
                                //ChartTraderControlQuantityEdit
                    
                                chartWindow                = System.Windows.Window.GetWindow(ChartControl.Parent) as NinjaTrader.Gui.Chart.Chart;
                                chartTraderGrid            = (Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader).Content as System.Windows.Controls.Grid;
                                buyMarketButton            = chartTraderGrid.FindFirst("ChartTraderControlQuickBuyMarketButton") as System.Windows.Controls.Button;
                                sellMarketButton        = chartTraderGrid.FindFirst("ChartTraderControlQuickSellMarketButton") as System.Windows.Controls.Button;
                    [B]quantityBox                = chartTraderGrid.FindFirst("ChartTraderControlQuantityEdit") as System.Windows.Controls.TextBox;[/B]
                    
                                originalButtonColor        = buyMarketButton.Background;
                    
                                if (TabSelected())
                                    ShowWPFControls();
                    
                                chartWindow.MainTabControl.SelectionChanged += TabChangedHandler;
                            }
                    Please let me know if I can assist any further.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      If I have win10 SDK installed and made a strategy/indicator, then exported it for another PC without Win10 SDK will it work there?

                      Comment


                        #12
                        Hi Andrew Sh, thanks for your question.

                        Yes, it would still work. NinjaTrader needs the .NET framework to run which most Windows installations have.

                        Kind regards.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you.

                          Comment


                            #14
                            Originally posted by NinjaTrader_ChelseaB View Post
                            Hello D Trader,

                            I do not have a complete list of the automation ids, but you can find these for any visible objects you need.

                            Below is a link to a video that demonstrates how to use the Microsoft Inspect tool to find automation ids of wpf objects in existing programs.
                            This video demonstrates where to find the Microsoft Inspect tool from the Windows 8.1 SDK (installed with Visual Studio) and how to use this to find Automation Ids and view the parent child hierarchy.


                            (edit)
                            A small note, modifying the existing chart window or chart trader area or any other part of the NinjaTrader interface that is not in your own addon window would fall under undocumented.

                            Below is a link to the help guide on addons.
                            http://ninjatrader.com/support/helpG...-us/add_on.htm
                            Hi ChelseaB, I would like to watch the video https://www.screencast.com/t/mhpROfCtsa , unfortunately the flash player is no longer available. Do you have an alternative?

                            sidlercom80
                            NinjaTrader Ecosystem Vendor - Sidi Trading

                            Comment


                              #15
                              Hello sidlercom80,

                              I've uploaded to google drive.
                              This video demonstrates where to find the Microsoft Inspect tool from the Windows 8.1 SDK (installed with Visual Studio) and how to use this to find Automation Ids and view the parent child hierarchy.


                              Also, below is a link to another thread on the subject of MSInspect.
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gyilaoliver, Today, 03:31 AM
                              5 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by leojimenezp, Today, 08:40 AM
                              3 responses
                              9 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by ZeroKuhl, Today, 10:22 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by mtamaku, Yesterday, 11:08 AM
                              11 responses
                              26 views
                              0 likes
                              Last Post mtamaku
                              by mtamaku
                               
                              Started by vit007, Today, 05:09 AM
                              3 responses
                              28 views
                              0 likes
                              Last Post backtester831  
                              Working...
                              X