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

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.
    Kate W.NinjaTrader Customer Service

    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.
                  Kate W.NinjaTrader Customer Service

                  Comment


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

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Irukandji, Today, 05:50 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post Irukandji  
                    Started by ageeholdings, Today, 05:22 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post ageeholdings  
                    Started by llanqui, 04-28-2024, 10:32 AM
                    2 responses
                    19 views
                    0 likes
                    Last Post llanqui
                    by llanqui
                     
                    Started by DroneBlackCa, Today, 05:17 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post DroneBlackCa  
                    Started by tradingnasdaqprueba, 04-09-2024, 09:52 AM
                    7 responses
                    50 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X