Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TimePicker

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

    TimePicker

    I'm trying to add hh:mm time picker to properties. I found this



    but wondered if there were any samples or documentation that would help me?​

    #2
    Hello, thanks for writing in. This is not documented, but you can use a time picker with these type converters:

    Code:
    [NinjaScriptProperty]
    [XmlIgnore()]
    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
    [Display(Name = "MyTime")]
    public DateTime MyTime
    { get; set; }​
    With Seconds:
    Code:
    [NinjaScriptProperty]
    [XmlIgnore()]
    [PropertyEditor("NinjaTrader.Gui.Tools.AutoCloseTimeEditorKey")]
    [Display(Name = "MyTime")]
    public DateTime MyTime
    { get; set; }​
    Kind regards,
    -ChrisL
    ​​

    Comment


      #3
      if I want to initialize myTime = new DateTime(Time[0].Year,Time[0].Month,Time[0].Day,9,30,0,0) where do I do this ? don't think is likes State.SetDefaults

      Comment


        #4
        Hello, thanks for the follow-up. You will initialize this variable in State.SetDefaults, but you can not use Time[0] in a non data driven event, especially if data has not loaded yet. You would want to either use DateTime.Now.Year, DateTime.Now.Month and so on to get the system time or call this in OnBarUpdate.

        Comment


          #5
          ok thanks, if I use State.SetDefault, it compiles of but no longer appears on the chart strategy selection list so.

          I'll use OnBarUpdate with if (CurrentBar == 0)

          i'm just trying to initilialize time1 property to 09:15 to it shows up in the UI as 09:30.

          [NinjaScriptProperty]
          [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKe y")]
          [Display(ResourceType = typeof(Custom.Resource), Name = "time1", GroupName = "Trading", Order = 1)]
          public DateTime time1
          { get; set; }​


          Last edited by dibDab; 02-15-2023, 09:07 AM.

          Comment


            #6
            Hi, You can initialize it to this time like this in State.SetDefaults:

            time1 = DateTime.Parse("9:15", System.Globalization.CultureInfo.InvariantCulture) ;

            Comment


              #7
              ok thanks, how do I test if a bar time is in a range e.g. between time1 and time2?

              time1 = DateTime.Parse("9:15", System.Globalization.CultureInfo.InvariantCulture) ;
              time2 = DateTime.Parse("10:15", System.Globalization.CultureInfo.InvariantCulture) ;

              Comment


                #8
                Hi, We have an existing example that shows how to set up a time filter here:

                To use the two DateTime variables use ToTime to convert it to a simple int variable:

                if ((ToTime(Time[0]) >= ToTime(time1) && ToTime(Time[0]) < ToTime(time2))

                Comment


                  #9
                  There are several (undocumented) property editor tools that are very useful when selecting DateTime or TimeSpan properties, including:
                  • NinjaTrader.Gui.Tools.AutoCloseTimeEditorKey
                  • NinjaTrader.Gui.Tools.ChartAnchorTimeEditor
                  • NinjaTrader.Gui.Tools.DateTimeConverter
                  • NinjaTrader.Gui.Tools.TimeEditorKey​
                  These work well when part of a Property Grid for Indicators or Strategies.

                  How can any of these be included in a WPF Grid in an AddOn as a UIElement, to allow specification of DateTimes in a grid, not specifically as a property?

                  Thanks.
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment


                    #10
                    Hello jeronymite,

                    Property attributes are only used in the property grids and do not generate controls in an addon.

                    In an addon you would need to use custom C# to create the controls.

                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    650 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    370 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    577 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X