Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Properties persistence, attributes

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

    Strategy Properties persistence, attributes

    Hello,

    actually while testing


    I noticed a strange behaviour concerning the Properties of a strategy in a Disable/enable cylce of a strategy.

    Lets assume I have a property

    public string STRING1 {
    ...

    }

    when going through a Enable/Disable cycle, this should not change.

    OK, above property will do so.

    But if I apply the attribute

    [Browsable(false)]
    public string STRING1 {

    }

    then the property is not persistent and reset to zero each time the strategy is enabled.

    Please explain the idea behind this (or is it a simple bug?)

    Will the attribute [XmlIgnore] behave as expected?

    Attached a sample strategy. Uncomment //[Browsabe ] to produce the - in my view wrong behaviour.

    regards

    andreas
    Attached Files

    #2
    zweistein,

    Let us take a step back. What are you trying to achieve? You cannot hide/ignore parameters like that. Those are for plots, not parameters.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I am not trying to ignore a property.

      I just need the value internally and there is no need for me to display them in the Properties. Therefore [Browsable(false)].
      For the sake of get things working I just removed the [Browsable(false)] attribute and then the behaviour is as exected.

      The example strategy given is clear. Please check and explain the -unexpected- behaviour.


      regards
      Andreas

      P.S. I am working on a proper continuation of my strategies in an overnight scenario. Hence I save order.token strings in the strategy properties. These tokens are needed to find out what has happened with my position during the overnight period. (still in position or stopped out).

      Comment


        #4
        I have forwarded your question to development for clarification.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          zweistein,

          Development has taken a look and this will be the case when you use [Browsable(false)].

          What we would like to determine is what are your requirements or use-case for something like a parameter that is not browsable? Why make it a parameter at all then? Thanks for the clarification info you can provide.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Hello Josh,

            >>What we would like to determine is what are your requirements or use->>case for something like a parameter that is not browsable? Why make it >>a parameter at all then? Thanks for the clarification info you can >>provide.

            What I want is: In a Strategy I want to use properties and its relative attibutes the same way as used by MSDN and standard C#, for the attribute Browsable see the following link.

            In my particular case I need to keep track of order tokens which I save as string properties of my strategy.

            I do not understand you mentioning "parameter". What is a parameter for you?
            A. Do you define a parameter as a Property with Attribute GridCategory("Parameters")?

            B. Do you define Parameter any Property of a class derived from StrategyBase, even without the GridCategory("Parameters") Attrribute?


            I am asking you because the "strange behaviour" describred is indipendent of the GridCategory of the Property. Even if I omitt GridCategory completely the behaviour remains "strange" and the Property is placed automatically in the "Misc" category.

            What I wanted is just hiding the Property from visual display because I use it as an internal variable. By choosing it to be a property I would like to use the Serializable features that are automatically included with a variable beeing a public Property.
            (see http://msdn.microsoft.com/en-us/libr...hh(VS.71).aspx ,
            says )

            regards
            Last edited by zweistein; 04-10-2010, 11:43 PM.

            Comment


              #7
              There may be some confusion:

              - 6.5: strategy parameters are tagged with Category("Parameters"). Anything else may or may not have worked. You should NOT tag such parameter with Browsable(false).

              - 7: strategy parameters now are tagged with GridCategory("whatEverNameYouLiked") to provide you more flexibility. You should NOT tag such parameter with Browsable(false), same as 6.5, nothing has changed.
              Any other "non-parameter" property you could tag (if needed) with Category("whatEverNameYouLiked"). DON'T use GridCategory for those.

              Comment


                #8
                Hello Dierk,

                thanks for enlighting.
                As I understand you are saying that as long as a property does not have a GridCategory("Parameters") attribute it it not considered a strategy parameter. Hence in such a case Browsable(false) can be used and will work as per MSDN C# documentation.
                Correct?


                My findings with MyCustomStrategy are however different:

                just modify the property attributes to (comment out GridCategory)

                //[Description("")]
                //[GridCategory("Parameters")]
                [Browsable(false)]
                publicstring STRING1
                ...



                and you will see that also this -non Parameter - property will be reset to "" each time you go through a Enable/Disable cycle of the strategy.
                I would say this is a bug.

                Thank you for enlighting further

                Andreas



                P.S. In my view the problem arises from a particular NinjaTrader behaviour: All Properties of a strategy get ALWAYS tagged by NinjaTrader: If no tag is found then the "Misc" tag is automatically applied. This is done internally by NinjaTrader.
                So my question: How to disable automatic tagging of strategy properties by NinjaTrader?
                Last edited by zweistein; 04-11-2010, 09:55 AM.

                Comment


                  #9
                  As you enable a strategy a new instance is created and started. The new instance is created as a clone. Only those properties which are Browsable(true) will be cloned. Same applies to indicators. This is "since day 1" logic which I'd rather not touch to not break stuff.

                  Comment


                    #10
                    Thinking about a resolution to that issue... you could overwrite the Clone() method, call base.Clone() first and then clone your Browsable(false) properties.

                    Comment


                      #11
                      Thanks Dierk,

                      I tried it and your suggestion works, excellent!

                      regards

                      Comment


                        #12
                        Great, thanks for your feedback.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Torontobluejays, Today, 08:43 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post Torontobluejays  
                        Started by sastrades, 01-31-2024, 10:19 PM
                        12 responses
                        186 views
                        0 likes
                        Last Post sastrades  
                        Started by Jimmyk, 01-26-2018, 05:19 AM
                        8 responses
                        863 views
                        0 likes
                        Last Post emuns
                        by emuns
                         
                        Started by giulyko00, 04-24-2024, 12:03 PM
                        6 responses
                        29 views
                        0 likes
                        Last Post giulyko00  
                        Started by 00nevest, 04-27-2024, 02:27 PM
                        3 responses
                        27 views
                        0 likes
                        Last Post 00nevest  
                        Working...
                        X