• 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 xsgex, Yesterday, 09:46 PM
    0 responses
    2 views
    0 likes
    Last Post xsgex
    by xsgex
     
    Started by Steve L, Yesterday, 09:36 PM
    0 responses
    1 view
    0 likes
    Last Post Steve L
    by Steve L
     
    Started by krugman25, Yesterday, 09:34 PM
    0 responses
    4 views
    0 likes
    Last Post krugman25  
    Started by indy73, Yesterday, 04:42 PM
    0 responses
    15 views
    0 likes
    Last Post indy73
    by indy73
     
    Started by Italianforex, Yesterday, 06:20 AM
    2 responses
    13 views
    0 likes
    Last Post gplatis
    by gplatis
     
    Working...
    X