• 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

    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!
    daqu40
    NinjaTrader Ecosystem Vendor - QTradez

    #2
    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.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      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!
      daqu40
      NinjaTrader Ecosystem Vendor - QTradez

      Comment


        #4
        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!
        daqu40
        NinjaTrader Ecosystem Vendor - QTradez

        Comment


          #5
          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.
          JesseNinjaTrader Customer Service

          Comment


            #6
            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?

            daqu40
            NinjaTrader Ecosystem Vendor - QTradez

            Comment


              #7
              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.

              JesseNinjaTrader Customer Service

              Comment


                #8
                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?
                daqu40
                NinjaTrader Ecosystem Vendor - QTradez

                Comment


                  #9
                  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.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Jesse,

                    I'll use the constructor and CleanUp.
                    daqu40
                    NinjaTrader Ecosystem Vendor - QTradez

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by simjs, Yesterday, 08:11 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post simjs
                    by simjs
                     
                    Started by mrlucky1x, Yesterday, 06:01 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post mrlucky1x  
                    Started by dedouglas, Yesterday, 03:17 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Jugado, Yesterday, 02:22 PM
                    2 responses
                    30 views
                    0 likes
                    Last Post Jugado
                    by Jugado
                     
                    Started by login_dejavu, 04-21-2019, 04:58 AM
                    2 responses
                    24 views
                    0 likes
                    Last Post login_dejavu  
                    Working...
                    X