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

Determing NT8 Chart Trader Selected Account

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

    Determing NT8 Chart Trader Selected Account

    To NT8 Support:

    Would you please post a brief code example of the best way for my NT8 custom indicator / strategy code to find out which account the user has selected from the Chart Trader's account combo box?

    I have found examples of this for NT7, but not for NT8.

    What I am looking for is not how to iterate through all available accounts, but to determine specifically which account is currently selected. So, for instance, something like the following made-up pseudo-code examples:

    selAccount = Account.All.SelectedAccount;
    or
    selAccount = Account.All[ AccountComboBox.SelectedItem ]; // Must find Account combobox object on Chart Trader first.

    Thank you.

    #2
    Hello D Trader,

    I have put together an indicator which will print the current account selected in the Chart Trader drop down and attached the file.

    Please let us know if you need further assistance.
    Attached Files
    Last edited by NinjaTrader_AlanP; 05-02-2017, 10:15 AM.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Many thanks, Alan from NinjaTrader. Your example worked well.

      Can you point me to a list of the other Chart Trader control types and names? For example, TIF, Order Qty, the various display elements like PnL, Ask, Bid, etc? I think any programmer in the NT8 community would find it useful to be able to "read" the information selected or displayed on the Chart Trader panel.

      Thanks again.

      Comment


        #4
        Hello D Trader,

        You should see the following forum post for instructions on finding an automation ID,


        I have provided the following ID's you asked for, however be aware automation IDs can change during development.

        Date provided, 5-2-2017.

        Automation ID: WPF element: Object Class:
        ChartTraderControlTIFSelector: Chart Trader TIF menu: NinjaTrader.Gui.Tools.TifSelector:
        ChartTraderControlQuantityEdit: Chart Trader Order Quantity field: System.Windows.Controls.TextBox:
        ChartTraderControlPnLDisplay: Chart Trader PnL: NinjaTrader.Gui.Tools.PositionDisplay:
        ChartTraderControlAskPriceText: Chart Trader Current Ask: System.Windows.Controls.TextBlock:
        ChartTraderControlBidPriceText: Chart Trader Current Bid: System.Windows.Controls.TextBlock:

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Looking for help to build simple strategy. Spread Trading strategy. With links "GoShort" (mean short first instrument and long second instrument), "GoLong" (mean short first instrument and long second). Where can I start from?

          Comment


            #6
            Looking to build simple strategy. Any help appreciated. Spread Trading Strategy. With click to "GoShort" (mean short first instrument and long second instrument), "GoLong" (mean long first instrument and short second). Where can I start from? If can somebody post ready code from I can start, appreciated.

            Comment


              #7
              Hello condor,

              I built a sample indicator which when applied to a chart will display 2 buttons. Clicking button 1 will buy the ES 06-17 and at the same time sell 1 NQ 06-17. Button 2 will do the opposite.

              Please let us know if you need further assistance.
              Attached Files
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Thank you.
                How to plot Total PNL, and also how to change instruments and account

                Comment


                  #9
                  Hello Condor,

                  To set the PL to a plot you would want to see Account.Get section of our helpguide,


                  Available AccountItems can be found at the following link,


                  Once you've pulled the account PL, you would want to set it to a plot, see the following example.


                  Regarding changing instruments and account, what is it you are looking to do exactly?

                  I look forward to your reply.
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you so much. I really appreciate your help. I am looking similar that you indicator created with a little more option. I am looking for spread trade YM and NQ with profit target and stop loss, with available to see Total positions PNL. I just started learning NT Programming. I did some changes on your indicator. You can see on attached file.
                    To add options to change the account, do I need just copy and paste the code from NinjaTrader Help Guiges? One question about using chart tabs. I did not find the answer on NT Guge. When I add tabs on chart and change to a different account on chart trader it changes the same account on all charts. Is it passable to have different accounts on open tabs?
                    Attached Files
                    Last edited by condor; 05-12-2017, 08:01 AM.

                    Comment


                      #11
                      Hello Condor,

                      It is not possible to have two different accounts selected in chart trader on two different tabs, however I will submit a feature request for this. This feature request ID is SFT-2060.

                      Regarding the ability to change the account with the indicator I put together, you could pass a string variable containing the desired account in the myAccount assignment, so that you could change the account. You could see the SMA indicator preloaded on NInjaTrader for an example of creating a user input, however you’d want to use a string variable rather than an int.

                      Please let us know if you need further assistance.
                      Last edited by NinjaTrader_AlanP; 05-12-2017, 10:12 AM.
                      Alan P.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Condor,

                        It is not possible to have two different accounts selected in chart trader on two different tabs, however I will submit a feature request for this.

                        Regarding the ability to change the account with the indicator I put together, you could pass a string variable containing the desired account in the myAccount assignment, so that you could change the account. You could see the SMA indicator preloaded on NInjaTrader for an example of creating a user input, however you’d want to use a string variable rather than an int.

                        Please let us know if you need further assistance.
                        Alan P.NinjaTrader Customer Service

                        Comment


                          #13
                          Is there an indicator or a way to display on the screen, which account is active in the Chart Trader?

                          Comment


                            #14
                            Hello BigRol00,

                            Thank you for your reply.

                            Building off Alan's example in one of the posts above, you could create an indicator that calculates on each tick and checks to see if there's been a change in the selected account in the dropdown.

                            Here's a code example:

                            Code:
                            // class level variables
                            NinjaTrader.Gui.Tools.AccountSelector xAlselector;
                            private string AccountName;
                            
                            // in OnBarUpdate:
                            protected override void OnBarUpdate()
                            {
                            ChartControl.Dispatcher.InvokeAsync((Action)(() =>
                            {
                            //You have to put the stuff below within this ChartControl.Dispatcher.InvokeAsync((Action)(() =>, because you are trying to access something on a different thread.
                            xAlselector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
                            AccountName = xAlselector.SelectedAccount.ToString();
                            xAlselector.SelectionChanged += (o, args) =>
                            {
                            if (xAlselector.SelectedAccount != null)
                            {
                            AccountName = xAlselector.SelectedAccount.ToString();
                            }
                            };
                            }));
                            
                            Draw.TextFixed(this, "MyText", "Account Selected: " + AccountName, TextPosition.BottomRight);
                            }
                            Please let us know if we may be of further assistance to you.
                            Kate W.NinjaTrader Customer Service

                            Comment


                              #15
                              HI NinjaTrader_Kate thanks for this.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by arvidvanstaey, Today, 02:19 PM
                              4 responses
                              11 views
                              0 likes
                              Last Post arvidvanstaey  
                              Started by samish18, 04-17-2024, 08:57 AM
                              16 responses
                              61 views
                              0 likes
                              Last Post samish18  
                              Started by jordanq2, Today, 03:10 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post jordanq2  
                              Started by traderqz, Today, 12:06 AM
                              10 responses
                              18 views
                              0 likes
                              Last Post traderqz  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              5 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X