• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

TradingHours missing function

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

    TradingHours missing function

    TradingHours has a function GetPreviousTradingDayEnd(DateTime timeLocal)
    but it does not have a matching function say called
    GetPreviousTradingDayStart(DateTime timeLocal)
    To be honest a name like GetSessionStart(DateTime timeLocal) would be better, but GetPreviousTradingDayStart matches the existing naming convention.

    I know someone is going to say "use SessionIterator instead", but I want to be able to get the start of a session relative to a given DateTime in OnBarUpdate(), but as of RC2 the documentation for SessionIterator.GetNextSession() says
    calling this method for each bar in the OnBarUpdate() method would NOT be recommended.
    There is no such warning for TradingHours.GetPreviousTradingDayEnd() so I am assuming it is more efficient (and so the matching GetPreviousTradingDayStart should be also).

    So could NT add GetPreviousTradingDayStart(DateTime timeLocal)
    please.

    #2
    Hello DaveE,

    Thank you for your post.

    You could use Bars.BarsSinceNewTradingDay to calculate the bars back for the start of the session. Then pass this to Time.

    Bars: http://ninjatrader.com/support/helpG...en-us/bars.htm
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      BarsSinceNewTradingDay only works in the context of the current session, it does not allow finding the session start for an arbitrary DateTime, so it cannot substitute for the suggested function GetPreviousTradingDayStart(DateTime timeLocal)

      Comment


        #4
        SessionIterator is the ultimate core object used to traverse trading hours details over segments of time.

        GetPreviousTradingDayEnd() is no more efficient than using your own session iterator.

        Any helper methods we would create would simply wrap a session iterator object, and would need to call either sessionIterator.CalculateTradingDay or sessionIterator.GetNextSessionEnd to arrive at this information requested.

        We will submit your request to add this type of method to the TradingHours class, but in the meantime - go ahead and use your own session iterator.

        I also have requested an update to the help guide to reflect a similar performance concern
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hello DaveE,

          Thank you for your patience.

          This feature request has been assigned the ID SFT-1730.
          Patrick H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Duval, Today, 08:38 AM
          0 responses
          6 views
          0 likes
          Last Post Duval
          by Duval
           
          Started by i2w8am9ii2, 02-13-2019, 04:28 PM
          7 responses
          61 views
          0 likes
          Last Post sledge
          by sledge
           
          Started by woodyfox, Yesterday, 08:33 PM
          0 responses
          7 views
          0 likes
          Last Post woodyfox  
          Started by rblunsom, Yesterday, 11:19 AM
          2 responses
          29 views
          0 likes
          Last Post guidoisot  
          Started by drewski1980, Yesterday, 02:38 PM
          1 response
          22 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X