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

Add-On Development General NinjaScript development questions.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 02-10-2018, 06:33 AM   #1
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default NTWindow w/out TabControl?

Dear NT Team / All,

The example in helpguide for NTWindow has the following lines:
Quote:
// TabControl should be created for window content if tab features are wanted
TabControltc=newTabControl();
This suggests that NTWindow can be used without a tab control. Assuming I would indeed like to have a window w/out tabs (or tabcontrol), which element of NTWindow is capable of holding XAML? I don't think that NTWindow.Content acts is a container for XAML elements like Grid.

Thanks,
Roman
roman_ch is offline  
Reply With Quote
Old 02-11-2018, 02:57 PM   #2
NinjaTrader_AlanP
NinjaTrader Customer Service
 
NinjaTrader_AlanP's Avatar
 
Join Date: Apr 2016
Location: Denver, CO
Posts: 1,861
Thanks: 147
Thanked 383 times in 365 posts
Default

Hello roman_ch,

Thank you for your note.

At the following link you can import the Sample Addon Framework,
https://ninjatrader.com/support/help...t_overview.htm

That example will have tabs, however you could change the following line,

Code:
TabControlManager.SetCanAddTabs(tc, true);
To,

Code:
TabControlManager.SetCanAddTabs(tc, false);
And tabs will not be allowed to be created. This would be the easiest means of going about preventing the creation of new tabs in your chart window.

Xaml for this addon is Saved in AddOnFrameworkTab.xaml.

Please let us know if you need further assistance.
NinjaTrader_AlanP is offline  
Reply With Quote
Old 02-11-2018, 03:09 PM   #3
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Alan, thanks for taking time to respond. But this is obvious and I am not sure if my original Q was unclear.

It does not stike me as good use of time and resource to create a TabControl and a then add a Page to it for an NTWindow that needs not tabs. The helpguide in fact implies that this is not necessary.

So is there a way to use an NTWindow w/out a TabControl? If yes, which NTWindow element takes WPF controls?

Thank you,
Roman
roman_ch is offline  
Reply With Quote
Old 02-11-2018, 05:01 PM   #4
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,033
Thanks: 122
Thanked 1,782 times in 1,671 posts
Default

Hello Roman,

The NTWindow itself is a wpf Window which can host control elements directly.

You can also add a Page if you want.

Below are links to a few examples I've made.
https://ninjatrader.com/support/foru...059#post477059
NinjaTrader_ChelseaB is online now  
Reply With Quote
Old 02-12-2018, 03:35 AM   #5
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Hello Chelsea,

Thank you, that's excellent. Much appreciated.

Regards,
Roman
roman_ch is offline  
Reply With Quote
Old 02-12-2018, 06:02 AM   #6
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Hi Chelsea,

Thanks again for your reply. I have tested and, yes, NTWindow accepts WPF through Content and Page, just as you said. I have some follow up though - please could you take a look at the below.

The problem I was trying to resolve initially is my WPF windows not being closed / re-opened when workspaces are changed. I am not using these windows as part of an add-on (it would not be consistent with my model).

Obviously, NTWindow in the example implements IWorkspacePersistence interface. However, I've run into problems in testing just now with that.

Accordingly, could you let me know what exactly is required for an NTWindow (which is not part of add-on) so it is closed/re-opened with a change in the active workspace?

Thank you,
Roman
Last edited by roman_ch; 02-12-2018 at 06:12 AM.
roman_ch is offline  
Reply With Quote
Old 02-12-2018, 07:58 AM   #7
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,033
Thanks: 122
Thanked 1,782 times in 1,671 posts
Default

Hi Roman,

I have an example of this as well.
https://ninjatrader.com/support/foru...038#post510038
NinjaTrader_ChelseaB is online now  
Reply With Quote
Old 02-13-2018, 07:44 AM   #8
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Hello Chelsea,

Thank you. Appreciate you following up with this.

I have looked at the example, I stand to be corrected, but I think all NTWindows were created as part of an Add-On. Separately, I've run into to some issues with testing NTWindow (error re using "+" in a name, seems it is about internal names, though, as I do not have any such names).

To help me to figure out what might be the culprit, could you explain, how an NTWindow "syncs" with the worspace re activation.Can it be done w/out using an Add-On?

OK, I can see the interface re WorkspaceOptions, Restore() and Save(). And my guess that Restore and Save are called when Workspace is saved/restored, but I am not sure if that is what happens when Workspace changes. Same goes for Loaded (could it be something like Window.Hide() internally; and all my window data is bound to properties anyway.)

I think it all goes to the Q which bit of code "hides" the window?

Regards,
Roman
roman_ch is offline  
Reply With Quote
Old 02-13-2018, 11:47 AM   #9
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,033
Thanks: 122
Thanked 1,782 times in 1,671 posts
Default

Hello Roman,

There are no exposed NinjaTrader methods that activate when the workspace is changed and the windows visibility are changed.

But you might try adding a method to the IsVisibilityChanged event of the window object..


I'm not quite certain what you are trying to accomplish. What action are you trying to trigger when the visibility of a window is set back to visible?


Regarding the workspace options, just by your class inheriting from the IWorkspacePersistence interface, this causes ninjatrader to save the created NTWindow object of your class that has the interface applied when the workspace is saved.

When the workspace is opened, any NTWindow objects that had the interface applied are recreated.

Then once the window is created, NinjaTrader then trigger the Restore and Save methods so that you can set the saved values of the wpf elements and other things you wanted saved with that NTWindow.
NinjaTrader_ChelseaB is online now  
Reply With Quote
Old 02-13-2018, 04:21 PM   #10
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Hi Chelsea,

Thank you.

Quote:
There are no exposed NinjaTrader methods that activate when the workspace is changed and the windows visibility are changed.
I recall, think there is a developement request submitted for that.

The problem I am trying to resolve: my custom windows remain on-screen when I switch between two active workspaces (not closing any wrksp-s). I've attached two simple scripts to illustrate. The first scripts uses WPF. The second - NTWindow. Other than the base class, identical.

The WPF script works fine except that the window remains on-screen when I switch between active workpaces.

Re second script there are two items:
  1. it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?
  2. if it is made to work, and the interface implementation lines are uncommented, will the NT window be hidden when the active workspace is switched to another?
Thank you,
Roman
Attached Images
File Type: jpg WPF Win Test.jpg (175.4 KB, 4 views)
File Type: jpg NT Win Test.jpg (225.9 KB, 4 views)
Attached Files
File Type: cs MyWPFWinTest.cs (2.4 KB, 1 views)
File Type: cs MyNTWinTest.cs (4.3 KB, 1 views)
roman_ch is offline  
Reply With Quote
Old 02-13-2018, 04:27 PM   #11
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,033
Thanks: 122
Thanked 1,782 times in 1,671 posts
Default

Hello Roman,

From my understanding the core code in NinjaTrader will set the visibility of NTWindows to collapsed and will not work with other class types.

This is also true for the workspace persistence.


When you mention "it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?", what you are referring to here?

Are you talking about the string you are using for the workspace options instance?

Are you talking about the caption of the window?


Yes, even without workspace persistence implemented all NTWindows will still have the visibility set when the workspace is changed.
NinjaTrader_ChelseaB is online now  
Reply With Quote
Old 02-13-2018, 04:39 PM   #12
roman_ch
Member
 
Join Date: Feb 2016
Posts: 62
Thanks: 8
Thanked 5 times in 5 posts
Default

Hi Chelsea,

Quote:
When you mention "it generates a default re using "+" in a name, as per the screenshot. I do not see what causes this. Could you test it?", what you are referring to here?
I cannot make that code run at all. The screenshot shows the NTWindow script applied to the chart and below the log message I get in the control center.

Quote:
Are you talking about the string you are using for the workspace options instance?
No

Quote:
Are you talking about the caption of the window?
No

Quote:
Yes, even without workspace persistence implemented all NTWindows will still have the visibility set when the workspace is changed.
The NTWindow script does not run so I cannot test this. I am am without a clue what causes the default message and the exception. But it did run previously w/out the persistence interface (when you first replied with the AddOn example). However, then the NTWindow remained visible on workspace change.

So the Qs now are:
1. Does the NTWindow script I've sent work on your machine? 2. If yes, does the NTwindow collapse when active workspace changes?

R
EDIT: just tested, it is possible indeed to hook up to IsVisibleChanged and use that to manage WPF windows - thank you. Still be good to know re above two Qs.
Last edited by roman_ch; 02-13-2018 at 08:02 PM.
roman_ch is offline  
Reply With Quote
Old 02-14-2018, 09:43 AM   #13
NinjaTrader_ChelseaB
NinjaTrader Customer Service
 
NinjaTrader_ChelseaB's Avatar
 
Join Date: Dec 2012
Location: Denver, CO
Posts: 8,033
Thanks: 122
Thanked 1,782 times in 1,671 posts
Default

Hello Roman,

The MyNTWinTest script has the TestNTWindow within the indicator class..

Move this to the Addons namespace.

Below is a link to an example.
https://ninjatrader.com/support/foru...686#post492686
NinjaTrader_ChelseaB is online now  
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
What is NTWindow? texasnomad Add-On Development 3 10-16-2017 02:58 PM
Launching NTWindow soulfx Indicator Development 9 09-21-2017 08:47 AM
Missing documentation on NTWindow mmeninger Version 8 Beta 1 03-14-2016 02:04 PM
NTWindow Issue SystemTrading Version 8 Beta 2 01-25-2016 11:06 AM


All times are GMT -6. The time now is 08:59 AM.

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.