Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Add-On Development

Add-On Development General NinjaScript development questions.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 05-15-2018, 04:29 PM   #1
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 410
Thanks: 18
Thanked 34 times in 31 posts
Default 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.
aslane is offline  
Reply With Quote
Old 05-16-2018, 07:49 AM   #2
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 2,152
Thanks: 170
Thanked 452 times in 432 posts
Default

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.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 05-16-2018, 08:49 AM   #3
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 410
Thanks: 18
Thanked 34 times in 31 posts
Default

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.
aslane is offline  
Reply With Quote
Old 05-16-2018, 11:36 AM   #4
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 410
Thanks: 18
Thanked 34 times in 31 posts
Default

For setting the initial value of AccountSelector, use the DesiredAccount string in the constructor.
aslane is offline  
Reply With Quote
Old 05-16-2018, 01:18 PM   #5
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 2,152
Thanks: 170
Thanked 452 times in 432 posts
Default

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.

https://www.screencast.com/t/Ieu3AMFd

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.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 05-16-2018, 04:06 PM   #6
aslane
Senior Member
 
Join Date: May 2006
Location: Madison
Posts: 410
Thanks: 18
Thanked 34 times in 31 posts
Default

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.
aslane is offline  
Reply With Quote
Old 05-17-2018, 01:27 PM   #7
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 2,152
Thanks: 170
Thanked 452 times in 432 posts
Default

Hello aslane,

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

Thank you for your report.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 05-17-2018, 02:19 PM   #8
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 2,152
Thanks: 170
Thanked 452 times in 432 posts
Default

Hello aslane,

I have reported this as a bug.

Thank you for your report.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 05-21-2018, 01:10 PM   #9
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 2,152
Thanks: 170
Thanked 452 times in 432 posts
Default

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
File Type: zip AddOnFramework.zip (14.5 KB, 5 views)
NinjaTrader_AlanP is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"AccountSelector" Functionality w RRSP, TFSA, etc... Blairski Strategy Development 3 02-27-2018 01:14 PM
accountselector cleanup soulfx Add-On Development 3 06-16-2017 06:19 AM
AccountSelector change not changing strategy. GaryAlbers Strategy Development 2 03-21-2017 12:31 PM
How to export Output Window programmatically to a text file? ninjaq Strategy Development 12 03-25-2009 03:30 PM


All times are GMT -6. The time now is 10:55 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.