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

Bars.BarsSinceSession before Session Start time

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

    Bars.BarsSinceSession before Session Start time

    If the Session Start time = 930
    Session End Time = 1600

    If the time is 900 and I run Bars.BarsSinceSession is the result =-1 or does it report back -29? or something else

    Similary for after the Session end time what would I expect for Bars.BarsSinceSession? say it is 1615 what is the expectant result then?


    Regards

    #2
    Hello mefTrader,

    Thank you for your post.

    Bars.BarsSinceSession will be non-negative and start counting from zero starting at the first bar that opens after the session time.

    In your example, you are refering to times that are outside of defined session start and end times. These times won't exist in the context you're working from. There will not be a 9:00 bar or a 16:15 bar. There will be no strategy processing or indicator logic until 9:30.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      How do I check premarket?

      I currently have

      (ToTime(DateTime.Now) <= ToTime(9, 30, 00)

      Is my Session start time is 930

      how can I check if the current time is premarket i.e before 9,30,00 as in this case...

      Some thing like the following is what I want to do

      (ToTime(DateTime.Now) <= SessionStartTime

      can I do something like that?

      Comment


        #4
        Trying to make it generic! instead of a hard time i.e 9,30,00

        Comment


          #5
          (ToTime(DateTime.Now) <= ToTime(9, 30, 00)

          That statement will check your current system clock if before 9:30. This will only work in a live environment. (not backtesting)

          If you want it to check the system date/time against session start times, you can use the following:

          Code:
           
          if (ToTime(System.DateTime.Now) <= ToTime (Bars.SessionBegin))
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Nicholewatkinsi, Yesterday, 10:53 PM
          0 responses
          6 views
          0 likes
          Last Post Nicholewatkinsi  
          Started by dward123, 01-02-2024, 09:59 PM
          4 responses
          175 views
          0 likes
          Last Post Lancer
          by Lancer
           
          Started by ETFVoyageur, Yesterday, 04:00 PM
          2 responses
          19 views
          0 likes
          Last Post ETFVoyageur  
          Started by AaronKTradingForum, Yesterday, 03:44 PM
          1 response
          14 views
          0 likes
          Last Post AaronKTradingForum  
          Started by Felix Reichert, 04-26-2024, 02:12 PM
          11 responses
          80 views
          0 likes
          Last Post Felix Reichert  
          Working...
          X