Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Saving startegy parameters: DATETIME variable went retain default value

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

    Saving startegy parameters: DATETIME variable went retain default value

    Hello,
    On a startegy I am working on I use user definable datetimt objects. I would like to set default values by right clicking in the backtesting window and clicking "Set default"
    While this works for other parameters (of type bool, int or double) it does not work for the datetime variables.
    Can something be done?
    Thanks
    Tal

    #2
    Hello,

    Can you please share the code you are using where you see this behavior? In my testing, I was able to save the user defined Strategy DateTime input parameter as default from the strategy analyzer.

    Code:
    #region Variables
                
    		private DateTime myTime = new DateTime(2011,11,23,8,30,00); 
          
            #endregion
    Code:
     #region Properties
           	[Description("")]
    		[GridCategory("Parameters")]
    		public DateTime MyTime
    		{
    			get { return myTime; }
    			set { myTime = value; }
    		}
            #endregion
    MatthewNinjaTrader Product Management

    Comment


      #3
      wrong code...

      So it seems I've been using timespans types
      Code:
      private TimeSpan HWL_LongEnd;
      Code:
      [Description("HWL LongEnd")]
              [Category("Horizontal Wave Long Mode")]
              
      		public TimeSpan HWL_LONGEND
              {
                  get { return HWL_LongEnd ; }
                  set { HWL_LongEnd =  value; }
              }
      Will I need to change types, if so can I rely on the some propertys?

      Comment


        #4
        To serialize TimeSpan variables please use the following:

        Code:
            #region Properties
            		
        	[Description("HWL LongEnd")]
                [Category("Horizontal Wave Long Mode")]
                
        		public TimeSpan HWL_LongEnd
                {
                    get { return hWL_LongEnd ; }
                    set { hWL_LongEnd =  value; }
                }
        		
        		
        	[Browsable(false)]
        	public long HWL_LongEndSerialize
        
        	{
        		get { return hWL_LongEnd.Ticks; }
                        set { hWL_LongEnd = new TimeSpan.FromTicks(value); }
        	}
        				
                #endregion
        Last edited by NinjaTrader_Matthew; 06-12-2012, 07:38 AM.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hi Matthew,
          Thanks for your assistance.
          Unfortunately, I have implemented the code you provided but the problem has stayed the same. Hours are not saved.
          Is there anything else you can think of?
          Thanks
          Tal

          Comment


            #6
            Originally posted by talolard View Post
            Hi Matthew,
            Thanks for your assistance.
            Unfortunately, I have implemented the code you provided but the problem has stayed the same. Hours are not saved.
            Is there anything else you can think of?
            Thanks
            Tal
            You are missing a little piece of the serialization code.

            Code:
             
            [Browsable(false)]
            public long HWL_LongEndSerialize
             
            {
            get { return hWL_LongEnd.Ticks; }
            set { hWL_LongEnd = new TimeSpan[B][COLOR=red].FromTicks[/COLOR][/B](value); }
            }

            Comment


              #7
              Not quite there

              Hi,
              This is still not working.
              The code I have in place is
              Code:
              [Browsable(false)]
              	public long HWL_LongStartSerialize
              
              	{
              		get { return HWL_LongStart.Ticks; }
              		set { HWL_LongEnd = new TimeSpan.FromTicks(value); }
              	}
              But I get the error
              'System.TimeSpan.FromTicks(long)' is a 'method' but is used like a 'type'
              Your assistance is appreciated
              Tal

              Comment


                #8
                Originally posted by talolard View Post
                Hi,
                This is still not working.
                The code I have in place is
                Code:
                [Browsable(false)]
                    public long HWL_[COLOR=red]LongStart[/COLOR]Serialize
                 
                    {
                        get { return HWL_LongStart.Ticks; }
                        set { HWL_[COLOR=red]LongEnd[/COLOR] = new TimeSpan.FromTicks(value); }
                    }
                But I get the error
                Your assistance is appreciated
                Tal
                Why are you trying to set LongEnd while you are serializing LongStart?

                Comment


                  #9
                  Good point. But now that I've fixed that, I still have the same problem.
                  My Code is now
                  Code:
                  [Browsable(false)]
                  	public long HWL_LongStartSerialize
                  
                  	{
                  		get { return HWL_LongStart.Ticks; }
                  		set { HWL_LongStart = new TimeSpan.FromTicks(value); }
                  	}
                  And I get the same error as before
                  Thanks
                  Tal

                  Comment


                    #10
                    But it does work when I remove the new keyword.
                    Thanks
                    Tal

                    Comment


                      #11
                      Originally posted by talolard View Post
                      But it does work when I remove the new keyword.
                      Thanks
                      Tal
                      Yes, absolutely. For some reason, my eyes just glossed over the "new" keyword. It definitely should not be there. Good catch.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Max238, Today, 01:28 AM
                      3 responses
                      29 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Started by timko, Today, 06:45 AM
                      2 responses
                      12 views
                      0 likes
                      Last Post NinjaTrader_ChristopherJ  
                      Started by habeebft, Today, 07:27 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post habeebft  
                      Started by Tim-c, Today, 03:54 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by rocketman7, Today, 01:00 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X