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

Adding Strategy start/stop time in menu.

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

    Adding Strategy start/stop time in menu.

    On the "edit startegy" menu i would like to add the ability to change the start/stop time of my strategies. I know this has to be done in the unlocked version of my code. Is their a template available for this ?

    #2
    Hello Teebone21,

    Thanks for your post.

    You will need to create a User Defined Inputs for integers and then use those inputs to control logic using ToTime.

    An example that uses ToTime can be found here - https://ninjatrader.com/support/help...to_limit_t.htm

    ToTime documentation can be found here - https://ninjatrader.com/support/help...t8/?totime.htm

    Information on creating User Defined Inputs can be found here - https://ninjatrader.com/support/help...d_input_pa.htm

    You may also use a New Indicator/New Strategy Wizard to create User Defined Inputs and see the resulting syntax.

    New NinjaScript Wizards - https://ninjatrader.com/support/help.../ns_wizard.htm

    We look forward to asisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Teebone21 you mean like in the picture?
      Attached Files
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        try this:

        Code:
        protected override void OnStateChange()
        {
          if (State == State.SetDefaults)
          {
            Startzeit1 = DateTime.Parse("01:00", System.Globalization.CultureInfo.InvariantCulture);
            Endzeit1 = DateTime.Parse("22:00", System.Globalization.CultureInfo.InvariantCulture);
          }
        }
        Code:
         protected override void OnBarUpdate()
        {
          if (Times[0][0].TimeOfDay >= Startzeit1.TimeOfDay && Times[0][0].TimeOfDay <= Endzeit1.TimeOfDay)
          {
            ...your logic here...
          }
        Code:
        Properties
        ​​​​​​​
        [NinjaScriptProperty]
        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
        [Display(Name = "Session Start 1", Description = "Handelsstart Lokalzeit", Order = 1, GroupName = "Trading Session")]
        public DateTime Startzeit1
        { get; set; }
        
        [NinjaScriptProperty]
        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
        [Display(Name = "Session End 1", Description = "Handelsschluss Lokalzeit", Order = 2, GroupName = "Trading Session")]
        public DateTime Endzeit1
        { get; set; }
        sidlercom80
        NinjaTrader Ecosystem Vendor - Sidi Trading

        Comment


          #5
          Originally posted by sidlercom80 View Post
          try this:

          Code:
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Startzeit1 = DateTime.Parse("01:00", System.Globalization.CultureInfo.InvariantCulture);
          Endzeit1 = DateTime.Parse("22:00", System.Globalization.CultureInfo.InvariantCulture);
          }
          }
          Code:
           protected override void OnBarUpdate()
          {
          if (Times[0][0].TimeOfDay >= Startzeit1.TimeOfDay && Times[0][0].TimeOfDay <= Endzeit1.TimeOfDay)
          {
          ...your logic here...
          }
          Code:
          Properties
          ​​​​​​​
          [NinjaScriptProperty]
          [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
          [Display(Name = "Session Start 1", Description = "Handelsstart Lokalzeit", Order = 1, GroupName = "Trading Session")]
          public DateTime Startzeit1
          { get; set; }
          
          [NinjaScriptProperty]
          [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
          [Display(Name = "Session End 1", Description = "Handelsschluss Lokalzeit", Order = 2, GroupName = "Trading Session")]
          public DateTime Endzeit1
          { get; set; }
          Yes sir thanks !!!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by timmbbo, Today, 08:59 AM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by KennyK, 05-29-2017, 02:02 AM
          2 responses
          1,280 views
          0 likes
          Last Post marcus2300  
          Started by fernandobr, Today, 09:11 AM
          0 responses
          2 views
          0 likes
          Last Post fernandobr  
          Started by itrader46, Today, 09:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by bmartz, 03-12-2024, 06:12 AM
          5 responses
          33 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Working...
          X