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

FirstBarOfSession true twice in a day

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

    FirstBarOfSession true twice in a day

    I am using FirstBarOfSession to reset a counter at the beginning of each trading session. However, I've noticed that it returns to true at least twice a day; once at the beginning and again about an hour (give or take) later. Am I misunderstanding FirstBarOfSession?

    #2
    Hello ricktek,

    FirstBarOfSession is going to be based on what session template that you are using, so it would be possible to have multiple FirstBarOfSession. For example, if you use the ES the default Session Template (CME US Index Future ETH) is going to start at 5:00 PM CT Sunday through Thursday so you can expect the FirstBarOfSession to happen on 1 time each day at 5:00 PM CT.

    Another example would be the YC (Mini-size Corn) that uses a different session template (CBOT Agriculturals Mini ETH) which would happen once on Sunday at 6:00 PM CT, twice on Monday through Thursday at 9:30 AM CT and 6:00 PM CT, and once again on Friday at 9:30 AM CT.

    You may view/edit/create session templates in the Session Manager window. You may access the Session Manager by going to Tools > Session Manager. Below is a link to the Session Manager section of our help guide.

    * http://www.ninjatrader.com/support/h...on_manager.htm
    JCNinjaTrader Customer Service

    Comment


      #3
      I understand that and it all makes sense. My code simply resets a counter:
      if (FirstBarOfSession)
      counter = 0;

      The counter is being reset twice at the beginning of the session and again approx. one hour later. That, I was not expecting.

      Comment


        #4
        Hello ricktek,

        What session template are you using?

        Also could you clarify what you are expecting?
        JCNinjaTrader Customer Service

        Comment


          #5
          It happened using Default 24/7 and Forex. I was expecting that FirstBarOfSession == true when current bar is the first bar of the session (i.e., the current bar's time is the same as the time of the beginning of a session). I was not expecting FirstBarOfSession == true at any other time.

          Comment


            #6
            Hello ricktek,

            Thanks for the clarification.

            The FirstBarOfSession does not have to be at the same time as the beginning of the Session template it just has to be the first bar at the time of the new session or greater. So if data is only available after 5:00 PM CT using then even using the Default 24/7 Session Template the FirstBarOfSession will be at 5:01 PM CT.

            NinjaTrader Charts also work off of your PC Clock settings and time zone so it depending on what time zone you have your clock set to it could be possible to have 2 FirstBarOfSession in one day.

            Example: Using an ES 06-13 1 Minute Chart. Time Zone on PC set to Central Time. Loading back 5 days worth of data. You will get the following time stamps for the FirstBarOfSession (FBOS)

            FBOS: 4/21/2013 5:01:00 PM
            FBOS: 4/21/2013 11:01:00 PM
            FBOS: 4/22/2013 11:01:00 PM
            FBOS: 4/23/2013 11:01:00 PM
            FBOS: 4/24/2013 11:01:00 PM
            FBOS: 4/25/2013 11:01:00 PM

            So you would have 2 FBOS since data would start at 5:00 PM CT on Sunday 04/21/2013 which would be the first one, and 1 again at 11:01 PM CT which would be when the next Session Break would be since the Default 24/7 Session Template is defined as 12:00 AM to 12:00 AM ET. So there would be a 1 hour time difference.
            JCNinjaTrader Customer Service

            Comment


              #7
              There is a one hour difference between my PC's time and ET so that more or less explains it. I assume there is probably a small difference between my PC's time and ET to which NT has access; that would explain why it is not exactly a one hour difference. Thanks for the info. Come Monday, I'll find a work around.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,602 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              12 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X