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 Shansen, 08-30-2019, 10:18 PM
          24 responses
          938 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          3 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          2 views
          0 likes
          Last Post rocketman7  
          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  
          Working...
          X