Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Parameter

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

    Time Parameter

    I have the following time parameter for a set in one of my strategies:
    Time > 6:45 a.m.
    This morning my strategy executed at the open of trading 6:30 a.m. based on the last bar of the Friday session. How do I prevent the strategy from entering based on the bar of the prior session?

    #2
    Hi jrTrader,

    It depends how the time filter is coded exactly. If you have access to the source code, can you please share the code snippet?

    If you're using this, for example:
    if (ToTime(Time[0]) > 64500)

    That will look at all the time stamps of the bars and convert into an integer. The time format is a 24 hour clock and the ToTime() method turns the hhmmss portion into an integer. The time check above is true for all the bars from 6:45:01 AM until 11:59:59 PM.

    There are a few solutions to this- like checking day of week, setting an upper time limit, or using custom session templates. If you are not the author of the strategy, best is to contact them for support.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      It's actually generated in the strategy wizard. The condition reads ToTime(Time[0]) > ToTime(6, 45 , 0)
      The instrument traded is the es and I use the stock rth template.

      Comment


        #4
        Thanks for the reply. You'll likely want to set an upper bound on the time filter. Use something that is lower than the last time stamp of the day as marked by your session template. This would be added to the same set as your other entry conditions.

        if (ToTime(Time[0]) < ToTime(13, 15 , 0))

        There is also a sample available on time filters you can refer to here, that can help with adding other conditions like DayOfWeek.
        Last edited by NinjaTrader_RyanM1; 03-14-2011, 03:18 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Cool, that makes sense. Thanks.

          Comment


            #6
            Stop from trading at variable times

            Hi,

            I downloaded the sample but I want to make it variable without accessing the code each time. I have created the variables but need some brackets or somthing to make it recognise it as an int. Not sure what to put in??

            I am in Australia and want to stop from 4am (YFintime) to 830am (XBegtime) but I want to run it through the optimizer to get a better fit.

            if ((ToTime(Time[0]) >= 1 && ToTime(Time[0]) <= (YFintime)) || (ToTime(Time[0]) >= (XBegtime) && ToTime(Time[0]) < 240000))

            Thanks Raef

            Comment


              #7
              raefon72, what type are your YFin and XBeg varialbes you compare to here?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Not sure wizard applied variables I believe.

                privateint xbegtime = 1; // Default setting for XBegtime
                privateint yfintime = 1; // Default setting for YFintime

                There is anotherr section at the bottom that mentions them
                [Description("")]
                [GridCategory(
                "Parameters")]
                publicint XBegtime
                {
                get { return xbegtime; }
                set { xbegtime = Math.Max(1, value); }
                }

                Comment


                  #9
                  raefon72, can you please attach the script or send it to me at support at ninjatrader dot com so I could give it a run for you here?
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Bertrand,

                    I Found the error I believe it was because I used 2 capitals at the begginning of the variable (XBegtime) I have changed it to (Xbegtime). It seems to work fine now.
                    Thanks for the help.

                    ///<summary>
                    /// Called on each bar update event (incoming tick)
                    ///</summary>
                    protectedoverridevoid OnBarUpdate()
                    {
                    // Condition set 1
                    if ((ToTime(Time[0]) >= 1 && ToTime(Time[0]) <= (Yfintime)) || (ToTime(Time[0]) >= (Xbegtime) && ToTime(Time[0]) < 240000))
                    if (EMA(Fastema)[1] >= EMA(Slowema)[1])

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rexsole, Today, 08:39 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post rexsole
                    by rexsole
                     
                    Started by trilliantrader, Yesterday, 03:01 PM
                    3 responses
                    30 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    4 responses
                    26 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by Brevo, Today, 01:45 AM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by rjbtrade1, 11-30-2023, 04:38 PM
                    2 responses
                    74 views
                    0 likes
                    Last Post DavidHP
                    by DavidHP
                     
                    Working...
                    X