Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Anomaly with TimeSpan Parameters

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

    Anomaly with TimeSpan Parameters

    Hello,

    I have written a strategy that allows the user to change various TimeSpan parameters. There are currently 3 users. Two of us have no issues with seeing the default parameter values that get loaded on the chart.

    One user, however, does not see the default values of the TimeSpan parameters in the window. He sees 00:00:00 for all TimeSpan parameters. All of the other parameter types (i.e. int, double, etc.) display their default values as expected.

    Is there some setting that controls this behavior? Why would it affect some users and not others? I am not sure how to remedy this behavior.

    Thank you.

    Isaac

    #2
    Hello ivb73077,

    Are you certain all users are using the exact same version of the code?

    Does this user have an indicator template saved?
    (Documents\NinjaTrader 7\templates\Indicator\<indicator name>)

    Is the span properly serialized?
    http://www.ninjatrader.com/support/f...t.php?p=124724
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks.

      I export the code to all users, so we are all using the same code.

      The TimeSpan is not used with any indicators. It is simply used to figure out the times of day during which trading is permitted. Why would indicator templates have any impact?

      Regarding serialization, I am not clear what I need to do? Does the user still pass in a TimeSpan which I then parse and pull out its value?

      In the example you provided, I give the user a TimeSpan parameter to set. They will set the value and pass it back to the strategy. The strategy will then convert from a TimeSpan to a String. But what do I need to do with this String? I need a TimeSpan parameter, not a String parameter. Sorry - but I am still a bit unclear.

      Comment


        #4
        ivb73077,

        Indicator templates hold the default values when an indicator is selected.

        If you make a template with 00:00:00 selected this will superimpose any default settings you have hard coded.

        Give it a try.

        Yes, the time span works the same, you just convert it to a string so you have save it with the workspace or a template. (Xml)
        This is only for how the value is set when the indicator is selected or saved. This won't affect how it is actually used in the script.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          What confuses me about the Indicator Settings is why this impacts the value of a TimeSpan given that there are no indicators used within the strategy?

          Comment


            #6
            Hello ivb73077,

            That was my mistake for saying indicator.

            Using a TimeSpan in a strategy is exactly the same thing.

            Only it would be a Strategy template instead.

            TimeSpans still have to be serialized in a strategy (or any script).
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              ok. i will try this out.

              Comment


                #8
                Hi Chelsea,

                You advised me on this previously and I thought it had been resolved. As I initially noted, the code is used by 3 users. Two of us have no issues, but the third sees 00:00:00 for any TimeSpan parameter in the window when loading strategies onto a chart.

                Here is the code I am using:

                private TimeSpan sessionStartTime = new TimeSpan (09,30,00);

                public TimeSpan SessionStartTime
                {
                get { return sessionStartTime; }
                set { sessionStartTime = value; }
                }

                [Browsable(false)]
                public string srl_SessionStartTime
                {
                get {return sessionStartTime.ToString();}
                set {sessionStartTime = TimeSpan.Parse(value);}
                }

                The 3rd user still sees 00:00:00. I cannot replicate the problem on my side, so I am not sure how to proceed.

                Aside from using the code above, are there any other code changes required in order to serialize the TimeSpan object and have it appear as (09:30:00) for all users?

                Thank you.

                Comment


                  #9
                  Hello ivb73077,

                  I recommend that you double check he is running the latest version of the code, then delete any existing template files (with the same name as the indicator) so these can be remade.

                  Templates are located in Documents\NinjaTrader 7\templates\Indicator or Strategy depending on the script.

                  Let me know if that does not correct the issue and we can work with the client to see whats going on.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Just to be clear, are there any other changes i need to make to my strategy code? I want to be sure there is nothing on my end that is causing the problem?

                    Comment


                      #11
                      Hi ivb73077,

                      I've made an example indicator to demonstrate.

                      If the code is the same between machines, then it will have the same behavior.
                      (This is why you should double check that the code is the same)
                      Attached Files
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Ah. I did not have:

                        [XmlIgnore()]

                        added to the declaration of the TimeSpan object. The other samples I had found did not include this.

                        Aside from this, my code is identical to your example.

                        Thank you.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by judysamnt7, 03-13-2023, 09:11 AM
                        4 responses
                        53 views
                        0 likes
                        Last Post DynamicTest  
                        Started by ScottWalsh, Today, 06:52 PM
                        4 responses
                        33 views
                        0 likes
                        Last Post ScottWalsh  
                        Started by olisav57, Today, 07:39 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post olisav57  
                        Started by trilliantrader, Today, 03:01 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post helpwanted  
                        Started by cre8able, Today, 07:24 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post cre8able  
                        Working...
                        X