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

Strategy Wizard - Setting Strategy START Date.

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

    Strategy Wizard - Setting Strategy START Date.

    I wanted to use the strategy wizard, to start strategy on a certain date. How would I configure it.

    Thank you,
    Chris

    #2
    Hello Chris,

    Thank you for writing in and welcome to the NinjaTrader Support Forum!

    Unfortunately, it would not be possible to compare the day value of the current bar to another day value. Only the time value for the current bar is a selectable option from within the Strategy Wizard.

    The code would need to be unlocked and this condition manually coded.

    As an example, let's say we only want to have the strategy do anything if the time of the current bar is March 1, 2016 or greater.

    Code:
    if (ToDay(Time[0]) >= ToDay(2016, 3, 1))
    {
         // do stuff
    }
    For more information about ToDay(), please take a look at this help guide link: https://ninjatrader.com/support/help...nt7/?today.htm
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thank you, What if I wanted specify time interval associated with that date. I turned the system on to trade a certain date, but wanted it to close out at 13:55 EST USA, the date qualifier still has system live into evening session.

      Comment


        #4
        if ((ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 120000) || (ToTime(Time[0]) >= 140000 && ToTime(Time[0]) < 154500))

        above code is just example of time intervals
        Last edited by Kubera2024; 03-27-2016, 08:28 AM.

        Comment


          #5
          Hello Kubera2024,

          Thank you for your response.

          You would combine the ToTime(Time[0]) conditions you need with the ToDay(Time[0]).

          Comment


            #6
            I've managed to unlock the code and implement time parameters into the code. However I would like to set the time from the parameters window when assigning strategy to a chart. I need to create two time variables:

            Starttime
            Stoptime

            Otherwise each time I want to change it, I have to go into the code to change it. How would the code look for the above.

            ThankYou!
            Chris

            Comment


              #7
              I solved it, you have to declare the variables

              starttime
              stoptime

              as int

              #region Variables

              private int starttime = 083000;
              private int stoptime = 155500;

              #endregion

              and also in parameters section at bottom of code.

              each variable needs a separate

              #region Properties
              [Description("")]
              [GridCategory("Parameters")]
              public int Starttime
              {
              get {return starttime;}
              set { starttime = Math.Max(1, value);}
              }
              #endregion
              Last edited by Kubera2024; 04-10-2016, 10:30 AM.

              Comment


                #8
                Originally posted by Kubera2024 View Post
                if ((ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 120000) || (ToTime(Time[0]) >= 140000 && ToTime(Time[0]) < 154500))

                above code is just example of time intervals

                you can substitute times with variables

                if ((ToTime(Time[0]) >= starttime && ToTime(Time[0]) < stoptime))

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                27 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 02-22-2024, 01:11 AM
                5 responses
                32 views
                0 likes
                Last Post wzgy0920  
                Started by wzgy0920, 04-23-2024, 09:53 PM
                2 responses
                49 views
                0 likes
                Last Post wzgy0920  
                Started by Kensonprib, 04-28-2021, 10:11 AM
                5 responses
                193 views
                0 likes
                Last Post Hasadafa  
                Started by GussJ, 03-04-2020, 03:11 PM
                11 responses
                3,235 views
                0 likes
                Last Post xiinteractive  
                Working...
                X