Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create a Time parameter

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

    How to create a Time parameter

    I am using NT8 RC1. I want a parameter that is only a time of day, not a complete DateTime. I created a new strategy using the Strategy Wizard and I specific "Time" as my parameter type. It created this code:
    Code:
            PreSessionStart                        = DateTime.Parse("9:00 AM");
    
            [NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name="PreSessionStart", Description="Opening time of pre-session", Order=1, GroupName="NinjaScriptStrategyParameters")]
            public DateTime PreSessionStart
            { get; set; }
    But in the strategy properties panel, the parameter looks like this:

    PreSessionStart 09/03/2016

    ...with a calendar widget to pick a date. How do I change this parameter definition so it will only accept a valid time value? I tried messing with the get/set code, but really screwed up NT8 to where it would not even open up the Strategies window! :-)

    Thanks!
    Bryan

    #2
    Hello Bryan,

    Thank you for your post.

    I will report this to development.

    To create a time parameter like you wish you can use TimeSpan. For example:
    • In OnStateChange() when checking SetDefaults:

    Code:
    		MyTime						= new TimeSpan(8,0,0);
    • In the Properties region of the code:

    Code:
    		[NinjaScriptProperty]
    		[Display(ResourceType = typeof(Custom.Resource), Name="MyTime", Description="MyTime", Order=1, GroupName="NinjaScriptStrategyParameters")]
    		public TimeSpan MyTime
    		{ get; set; }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    149 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    84 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    129 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    125 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    102 views
    0 likes
    Last Post CarlTrading  
    Working...
    X