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

AccountSelector does not update text when changed programmatically

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

    AccountSelector does not update text when changed programmatically

    I am instantiating an AccountSelector, and on the first callback to SelectionChanged (which is when the accounts are populated), I set the SelectedAccount to my desired value. The underlying selected value changes correctly, but the text in the underlying ComboBox still contains the prior account name.

    I have tried a lot of things but can not get that field to update with the new value.

    I also tried using the DesiredAccount property, but that did nothing.

    Could be a bug, but perhaps I am not doing something right? Any ideas?

    Also, in your AddOnFramework example (and the doc) the SelectionChanged logic has an issue because you unsubscribe from the new account instead of the previous account.

    #2
    Hello aslane,

    Thank you for your note.

    For the Combobox, what statement are you using to set the desired value? For example,

    Code:
    xComboBox.SelectedItem or xComboBox.Text.?
    Regarding the AddonFramework example, within private DependencyObject LoadXAML(), I add the following print statement under if(accountSelector.SelectedAccount != null),

    Code:
    NinjaTrader.Code.Output.Process(accountSelector.SelectedAccount.ToString(), PrintTo.OutputTab1);
    And see that you'd be subscribing to the new account after any old account subscriptions were unsubscribed. The note just above the unsubscribing statements in the script, // Unsubscribe to any prior account subscriptions, seems to accurately describe whats happening. When testing the behavior, the Addon appears to be correctly subscribed to the new account. Would you be able to provide steps which demonstrate your point?

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

    Comment


      #3
      It is trivial to see in the code and to reproduce the unsubscribe issue.

      When SelectionChanged is called, the current SelectedAccount is unsubscribed which is wrong. It should be the previous account. The same account is then subscribed. So you basically never unsubscribed the previous account.

      If you have two sim accounts and run the example framework add on, you can watch execution updates, and then change the account to another account, and then in another window make some trades in the original account. You will see those executions even though you should be unsubscribed.

      Comment


        #4
        For setting the initial value of AccountSelector, use the DesiredAccount string in the constructor.

        Comment


          #5
          Hello aslane,

          In the video, I first change the account to Account1 from Sim101, which if I understand correctly you are saying would be unsubscribing to the new Account1 not Sim101, however when I then place a trade on the dom to the SIM101 and hit Account values, it does not show the position which indicates that the subscription to the SIM101 account was unsubscribed from.

          Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


          Are you seeing something different?

          The Account Selector is going to be populated based on accounts available when connected, attempting to set this may be possible, however would be unsupported.

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

          Comment


            #6
            I should not have to do this but here we go:

            1. Use two sim accounts (i.e. Sim101 and TempSim)
            2. Start the AddOnFramework, likely defaults to Sim101
            3. Click OnExecutionUpdate to monitor executions
            4. Switch account to TempSim in the AddOnFramework -> should be monitoring TempSim now
            5. Now in a chartWindow with ChartTrader turned on, and account Sim101 selected buy/sell
            6. At this point the AddOnFramework will show the buy/sell executions even though they are for the wrong account <- reason being the Sim101 account was never unsubscribed
            7. If you now go switch the ChartTrader to account TempSIm and buy/sell, the AddOnFramework again shows the executions <- this is because that account is also subscribed.

            The code can not work as is.

            Comment


              #7
              Hello aslane,

              I was able to replicate and will follow up when I have more information.

              Thank you for your report.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Hello aslane,

                I have reported this as a bug.

                Thank you for your report.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Hello aslane,

                  I added temp account variable to hold the previous accounts value, so that upon a change its this account that is unsubscribed from rather than the new account.

                  I'll submit the revised AddonFramework for addition to the addon, but if you see any issue in the attached version, please let us know.

                  Thank you for bringing this to our attention.
                  Attached Files
                  Alan P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Barry Milan, Yesterday, 10:35 PM
                  5 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by DanielSanMartin, Yesterday, 02:37 PM
                  2 responses
                  13 views
                  0 likes
                  Last Post DanielSanMartin  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  13 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  12 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post nandhumca  
                  Working...
                  X