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

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; }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    192 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,234 views
    0 likes
    Last Post xiinteractive  
    Working...
    X