Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time and proprieties

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

    Time and proprieties

    Hello,

    I try to get date and time in the proprieties indicator of my indicator.

    If i use
    Code:
    MyDateTime = new DateTime(2020, 2, 10, 16, 00, 0);
    I only get the DATE in the proprieties indicator, same if i remove the date to only input the Time:
    Code:
    MyDateTime = new DateTime(16, 00, 0);
    I tried with
    Code:
    TimeSpan timeSpan = new TimeSpan(2, 14, 18);
    But no luck only date show up.

    How do i only get the time or both, does it have to do with the proprieties scipt?

    Code:
    [NinjaScriptProperty]
    [PropertyEditor("NinjaTrader.Gui.Tools.ChartAnchorT imeEditor")]
    [Display(Name="MyDateTime")]
    public DateTime MyDateTime { get; set; }
    TY

    #2
    Hello frankduc,

    Thank you for your note.

    If you're just looking for a time picker you can actually set one up in the Strategy Builder or in the Indicator Wizard. Here's a quick example I created in the Indicator Wizard:

    Code:
    public class aaaaaaTestDateTimeInput : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "aaaaaaTestDateTimeInput";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    [B]TestInput1 = DateTime.Parse("13:20", System.Globalization.CultureInfo.InvariantCulture) ;[/B]
    }
    else if (State == State.Configure)
    {
    }
    }
    
    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    }
    
    [B]#region Properties
    [NinjaScriptProperty]
    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
    [Display(Name="TestInput1", Order=1, GroupName="Parameters")]
    public DateTime TestInput1
    { get; set; }
    #endregion[/B]
    
    }
    }
    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Thank you Kate!
      I love you

      Comment


        #4
        Kate,

        Is it possible to get the time and the date. The time only get me the bar of the current day. What if i want 9:30 2 days ago?

        Ty

        Comment


          #5
          Hello frakduc,
          You can use as below:
          Code:
          In Set.Defaults,[INDENT]MyDateTime = DateTime.Parse("16:00", System.Globalization.CultureInfo.InvariantCulture);[/INDENT]
           In Properties,[INDENT][NinjaScriptProperty]
          [PropertyEditor("NinjaTrader.Gui.Tools.ChartAnchorTimeEditor")]
          [Display(Name="Entry Time", Order=0, GroupName="Parameters")]
          public DateTime MyDateTime
          { get; set; }[/INDENT]
          Hope it helps!

          Comment


            #6
            Hello Kinra,

            No it only return the time. You can get both seperatly but i dont know yet how to get both. Choose the time and the date.

            Comment


              #7
              Hello frakduc,
              Please find attached snapshot of my Indicator Settings with same inputs.
              Attached Files

              Comment


                #8
                Yes you are right you have the date and time but cant change the time. You are stuck with 16:00.

                Comment


                  #9
                  Hello frankduc,

                  Thank you for your reply.

                  No, their example actually does work. You can use the date picker to choose the date but you have to select in the field and type the desired time in.

                  I've made a quick video to demonstrate: https://www.screencast.com/t/2zMlrpT11

                  Alternatively it may be more user friendly to input the date separately from the time and then build a new DateTime out of those user inputs.

                  Please let us know if we may be of further assistance to you.

                  Comment


                    #10
                    My bad sorry
                    Thank you its true it is working.

                    Comment

                    Latest Posts

                    Collapse

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