Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enum property not serializing in strategy

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

    Enum property not serializing in strategy

    Hi,
    I'm probably doing something wrong, but ...
    I have an enum declare in my strategy:
    [Serializable]
    public enum MyEnum
    {
    Item1 = 0,
    Item2 = 1
    }
    and I have a property defined as:
    [Display(ResourceType = typeof(Custom.Resource), Name = "My Prop", Description = @"My Prop", Order = 1, GroupName = "Misc")]
    public MyEnum MyProperty
    { get ; set; }

    Everything works great except the following scenario when I am running the Strat Analyzer.
    I choose item2 from the dropdown that is displayed for MyProperty.
    I run the backtest or optimizer.
    All is well. It comes back with whatever results and MyProperty is still showing item1.
    I then recompile my strat.
    The dropdown for MyProperty changes back to item1.
    All other properties that are not an enum keep their values between compiles.
    What is the secret sauce I am missing?
    Thanks ... Ed

    #2
    Originally posted by edstaffin View Post
    Hi,
    I'm probably doing something wrong, but ...
    I have an enum declare in my strategy:
    [Serializable]
    public enum MyEnum
    {
    Item1 = 0,
    Item2 = 1
    }
    and I have a property defined as:
    [Display(ResourceType = typeof(Custom.Resource), Name = "My Prop", Description = @"My Prop", Order = 1, GroupName = "Misc")]
    public MyEnum MyProperty
    { get ; set; }

    Everything works great except the following scenario when I am running the Strat Analyzer.
    I choose item2 from the dropdown that is displayed for MyProperty.
    I run the backtest or optimizer.
    All is well. It comes back with whatever results and MyProperty is still showing item1.
    I then recompile my strat.
    The dropdown for MyProperty changes back to item1.
    All other properties that are not an enum keep their values between compiles.
    What is the secret sauce I am missing?
    Thanks ... Ed
    If you want Strategy Analyzer properties to survive recompilation, you have to save said parameters as a default template.

    Comment


      #3
      I'm not sure I understand. Are you telling me I have to click on the templates button and load a template each time? Why do the other properties I have seem to survive a compile?
      Thanks ... Ed

      Comment


        #4
        Originally posted by edstaffin View Post
        I'm not sure I understand. Are you telling me I have to click on the templates button and load a template each time? Why do the other properties I have seem to survive a compile?
        Thanks ... Ed
        No. I am saying that you need to save the parameters as the default template.

        Comment


          #5
          Hi,
          Thanks for the response.
          I am not familiar with the "default template." Could you point me to where I can read up on it? Better yet, if there is an example could you point me to that?
          Thanks ... Ed

          Comment


            #6
            Originally posted by edstaffin View Post
            Hi,
            Thanks for the response.
            I am not familiar with the "default template." Could you point me to where I can read up on it? Better yet, if there is an example could you point me to that?
            Thanks ... Ed
            Every picture tells a story.
            Attached Files

            Comment


              #7
              Hi,
              Thanks for the pic. I now understand. However, I don't get it. What's the difference between calling it "Default" and anything else. Why do other properties "survive" a recompile, yet an enum doesn't?
              I'm sorry, but either I'm being brain-damaged or NT is on this one. I suspect the latter! :-)

              Comment


                #8
                Originally posted by edstaffin View Post
                Hi,
                Thanks for the pic. I now understand. However, I don't get it. What's the difference between calling it "Default" and anything else. Why do other properties "survive" a recompile, yet an enum doesn't?
                I'm sorry, but either I'm being brain-damaged or NT is on this one. I suspect the latter! :-)
                "Default" is used by default, and so is used at first load/reload.

                It was the same in NT7. Without a new test, I do not remember offhand if in NT7, all values got reset to defaults or only the enums. For sure, the enums got reset. It used to annoy the heck out of me, especially because then setting a default template always used the defaults instead of resetting when I wanted it to. See how we all like to "have our cake and eat it too"?

                Comment


                  #9
                  That's what I thought. I'll take my marbles and go home now.
                  NT are you listening???
                  Thanks ... Ed

                  Comment


                    #10
                    FWIW, I saved to default and tried recompiling and it DID NOT survive the recompile. :-(

                    Comment


                      #11
                      Hello edstaffin,

                      Thanks for your posts and discussion with member koganam.

                      I can confirm that, using the latest build, that enums will not change when saved to the default template.

                      If the strategy analyzer is open with the strategy being compiled, the strategy analyzer will revert the enum but the template will remain unchanged.
                      Paul H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by thanajo, 05-04-2021, 02:11 AM
                      4 responses
                      470 views
                      0 likes
                      Last Post tradingnasdaqprueba  
                      Started by aa731, Today, 02:54 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post aa731
                      by aa731
                       
                      Started by Christopher_R, Today, 12:29 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post Christopher_R  
                      Started by sidlercom80, 10-28-2023, 08:49 AM
                      166 responses
                      2,237 views
                      0 likes
                      Last Post sidlercom80  
                      Started by thread, Yesterday, 11:58 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post thread
                      by thread
                       
                      Working...
                      X