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

Determining regular session close on 24hr chart

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

    Determining regular session close on 24hr chart

    I'm building a strategy which needs calculate two sets of pivot points--one set on a futures contract using regular hours (8:30AM - 3:15PM) H, L, C, and another set which uses 24 hours H, L, C. The chart on which the strategy will be placed includes the Globex session. I am extracting the regular session H,L,C from a 2nd data set with a bar interval of 30m. I start counting Highs and lows as soon as the 30m bar time = 9000000, meaning the first bar of the regular session. I stop counting Highs and lows when the bar time = 153000, meaning the last bar of the regular session (which actually ends at 15:15, but there are no trades between 15:15 and 15:30). All of my calculations work fine except that sometimes the regular session close which I take from the 30m bar which ends at 15:30 is off by a tick. I'm not sure why. Sometimes its correct, but other tiems the close doesn't match the close on my comparison chart which is a 30m chart set to session start/stop = 8:30AM/3:15PM.
    Do you know what the problem is?
    OR...is there an easier way of doing what I'm trying to do here, (i.e. extract regular session H,L,C from a 24hour chart which is not necessarily set to minute intervals)?

    Thanks,

    rsi77

    #2
    rsi77,

    If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      "If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as."

      So if I want to know the beginning of the session I would use

      if (ToTime(Time[0]) > 83000 and ToTime(Time[1]) < 83000)
      {
      start tracking H, L;
      }

      and

      if (ToTime(Time[0]) > 151500 and ToTime(Time[1]) < 151500)
      {
      RegSesClose=Close[1];
      }

      Am I understanding this correctly???

      Thanks

      Comment


        #4
        Not sure why you would check Time[0] and Time[1] also. The conditions you have outlined are mutually inclusive. If Time[0] > 8:30 for sure Time[1] < 8:30.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          No, if time[0] = 9:50 and time[1]=9:48 they are both > 8:30....I wanted to isolate the case where I'm looking at the first bar after 8:30.
          I'm not sure I understand what you're getting at.

          In any case I solved my problem by adding another data stream with 15m interval. It calculates regular session close properly every time.

          I still need the 30m bars because I'm using them to calculate MP numbers which are also part of my strategy.

          rsi77

          Comment


            #6
            Not sure I am following you. If you want the bar after 8:30 just check for time to be equal to the next bar. On 30 minute series that would mean 9:00. On 15 minute that would mean 8:45.

            In either case, since you have it resolved we will leave it at that.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              OK, I had forgotten that I had "=" instead of ">".

              So setting on bar update to false will make it work with 30m bars?

              Will this mean that the strategy will be slower since it's checking more often?

              Is there an advantage to keep using 15m bars with "on bar update = true" in terms of speed of the strategy?

              Thanks.

              Comment


                #8
                CalculateOnBarClose will not change your timestamps. On thirty minute bars Time[0] is always 9:30 for instance. You cannot check 9:15 timestamps on 30 min series because there will be no bars with that timestamp regardless of if you use true or false. You will still need 15min series.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  CalculateOnBarClose will not change your timestamps. On thirty minute bars Time[0] is always 9:30 for instance. You cannot check 9:15 timestamps on 30 min series because there will be no bars with that timestamp regardless of if you use true or false. You will still need 15min series.
                  But you said that the reason my 30m bars were getting inconsistent results could be due to CaluclateOnBarClose being set to true. How would changing it to false help? At this point I'm trying to learn something since I clearly don't understand this.

                  Thanks

                  Comment


                    #10
                    Misunderstanding, I suggested you use as a means for you to see exactly what data you have as a check. It does not change anything for the bars. Furthermore it does not change timestamps.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cre8able, Today, 03:20 PM
                    1 response
                    9 views
                    0 likes
                    Last Post cre8able  
                    Started by fiddich, Today, 05:25 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post fiddich
                    by fiddich
                     
                    Started by gemify, 11-11-2022, 11:52 AM
                    6 responses
                    804 views
                    2 likes
                    Last Post ultls
                    by ultls
                     
                    Started by ScottWalsh, Today, 04:52 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post ScottWalsh  
                    Started by ScottWalsh, Today, 04:29 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post ScottWalsh  
                    Working...
                    X