• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Templates for AddOns

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

  • daqu40
    replied
    Thanks Jesse,

    I'll use the constructor and CleanUp.

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello daqu40,

    I am unable to see any other NinjaTrader events that would be called here that would be better for the use case. This would likely need to happen around the same time when you construct your xaml so you could apply settings in addition to loading the UI. Cleanup would likely be the best place to save as the platform calls this override for all platform necessary events.

    I look forward to being of further assistance.

    Leave a comment:


  • daqu40
    replied
    Thanks Jesse,

    I'll try the approach of saving my own file for the last state of the tab.

    One last question for myself and the benefit of anyone following this thread. Are there any events that fire as a new NTTabPage is constructed or destroyed that would be better for loading/saving my properties than the NTTabPage constructor or the CleanUp?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello daqu40,

    As far as I am aware there is nothing documented for this kind of use that I could suggest. There is currently no native "preset" or "template" control system that is exposed to NinjaScript use. You would likely need to save/load your own file for the overall addon or each tab if you wanted to do this.

    Depending on how you wanted to approach this type of loading, you would likely need to make this part of the tab factory or the tab items constructor for loading settings. For saving you could add a button similar to the indicator preset save/load buttons to define a new default. It would also depend if you wanted general settings for the tabs or individual settings for each tab.



    I look forward to being of further assistance.

    Leave a comment:


  • daqu40
    replied
    Thanks Jesse,

    After more work I noticed the same behavior.

    So YES, I would like to save save the properties of the AddOn in a template or something similar. I see methods within the NTTabPage for Save and Restore. These are triggered when the Workspace is saved or opened. Are the events when the NTTabPage is opened or closed that can be used to trigger these methods?

    Leave a comment:


  • NinjaTrader_Jesse
    replied
    Hello daqu40,

    Thank you for the reply.

    I wanted to better understand your expectation and goal here. You noted
    "After close and open AddOn Framework".
    Are you saying that you are closing the window and reopening a new window?

    There is a difference between closing the addon window and saving it with the workspace, the IWorkspacePersistence interface is specifically for saving values in the workspace which I see working on my end using breakpoints. This happens only when saving a workspace that has changes or loading a non-open workspace. Closing the window and reopening the window will not trigger these events as IWorkspacePersistence is not a template or preset system.

    Are you looking for something to save as a template or defaults for the tab when you reopen a new window?

    I look forward to being of further assistance.

    Leave a comment:


  • daqu40
    replied
    I'm back. Something seems amiss here.

    I've worked with the example of AddOn_Framework_NinjaScript_Basic. In the examples you can see here, the only thing it is saving is the selected instrument.

    Configured pic: http://prntscr.com/m49fmh
    After close and open AddOn Framework: http://prntscr.com/m49ftj

    I've attempted to intercept the Save and Restore methods of both the NTTabPage and NTWindow classes with Visual Studio and the breakpoints are never hit. The code clearly shows that at least the instrument and account should be saved and restored. The instrument part works, but not the account.

    Code:
            
    // NTTabPage member. Required for storing elements to workspace
            protected override void Save(XElement element)
            {
                if (element == null)
                    return;
    
                // Save the currently selected account
                if (accountSelector != null && !string.IsNullOrEmpty(accountSelector.DesiredAccount))
                    element.Add(new XElement("Account") { Value = accountSelector.DesiredAccount });
    
                // Save the currently selected instrument
                if (Instrument != null)
                    element.Add(new XElement("Instrument") { Value = Instrument.FullName });
            }
    So I'm puzzled as to what is being called that saves the instrument, but doesn't save the account. If wish to save several other controls/properties in my AddOn I need to know which methods to add/edit to get the results.

    If someone could update the AddOn_Framework... example so it is able to save the account and a few other properties, I'm sure the whole community would benefit.

    Thanks!

    Leave a comment:


  • daqu40
    replied
    Thanks Patrick,

    Of course I found this code in the AddOn Framework after making this post.

    I should be good, but will post back here if I have any more questions.

    Thanks!

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello daqu40,

    Thank you for your post.

    You would need to look into the IWorkspacePersistence interface at the following link: https://ninjatrader.com/support/help..._interface.htm

    You can find an example of using the IWorkspacePersistence interface to save options in the AddOnFramework example at the following link: https://ninjatrader.com/support/help...t_overview.htm

    Please let me know if you have any questions.

    Leave a comment:


  • daqu40
    started a topic Templates for AddOns

    Templates for AddOns

    Hello Add-On Development Forum,

    I'm working on an AddOn with a variety of settings that I would like preserved with the Workspace so the AddOn is setup the way I left it if I close the AddOn or NT8.

    I've tried adding some properties to preserve the settings I want, but I'm finding they are not being serialized or recovered when the AddOn is created with a new instance or after an NT restart.

    Thanks!

Latest Posts

Collapse

Topics Statistics Last Post
Started by renehtx, Today, 03:51 PM
1 response
4 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by eidog2020, Today, 03:31 PM
0 responses
4 views
0 likes
Last Post eidog2020  
Started by Lowerlevel1, Today, 01:34 PM
1 response
3 views
0 likes
Last Post NinjaTrader_Jesse  
Started by Mykro, Today, 12:33 PM
1 response
8 views
0 likes
Last Post NinjaTrader_BrendanC  
Started by madams212121, Today, 12:03 PM
5 responses
25 views
0 likes
Last Post madams212121  
Working...
X