How to Add Complete Time Value Selector to NinjaTrader Parameters


Quite often we need to add a time selector to NinjaTrader indicator or strategy parameter list. The usual to do this would be like this:

        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
        [NinjaScriptProperty]
        [Display(Name = "Opening Range-End", GroupName = GlobalSettings, Order = 13)]
        public DateTime OpeningRangeEnd { get; set; }

Which will end up looking like this:


Now, the downside here is that there are no seconds in the selector. If you want to have seconds added you need to write the code like this:

        [PropertyEditor("NinjaTrader.Gui.Tools.AutoCloseTimeEditorKey")]
        [NinjaScriptProperty]
        [Display(Name = "OverNight Range-Start", GroupName = GlobalSettings, Order = 15)]
        public DateTime OverNightRangeStart { get; set; }

Which will result looking like the pic below: