• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #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; }
    Patrick H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by timko, Today, 08:18 AM
    0 responses
    0 views
    0 likes
    Last Post timko
    by timko
     
    Started by victorsmith, Today, 06:00 AM
    0 responses
    3 views
    0 likes
    Last Post victorsmith  
    Started by sohailashraf, Yesterday, 10:18 PM
    0 responses
    6 views
    0 likes
    Last Post sohailashraf  
    Started by jjnc2006, Yesterday, 07:36 PM
    0 responses
    15 views
    0 likes
    Last Post jjnc2006  
    Started by futurenick, Yesterday, 06:26 AM
    1 response
    15 views
    0 likes
    Last Post nkhoi
    by nkhoi
     
    Working...
    X