Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetPreviousTradingDayEnd returns wrong Day

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

    GetPreviousTradingDayEnd returns wrong Day

    I have a litte issue using GetPreviousTradingDayEnd.
    If i use it on
    Code:
    State == State.DataLoaded
    it returns the Day before the Chart Time frame (if the time frame is set to 5 Days it returns the Date 6 day before).
    If GetPreviousTradingDayEnd is called in
    Code:
    OnBarUpdate
    , it starts with the Day before the Time frame and counts up to the last trading day.

    So where do i have to call GetPreviousTradingDayEnd or how can i ensure that if i call it, it really returns the last day and dont need a few iterations to count up to the last day ?

    Im using NinjaTrader 8 and NinjaTrader Continuum demo datafeed.

    #2
    Originally posted by NovaPrime View Post
    I have a litte issue using GetPreviousTradingDayEnd.
    If i use it on
    Code:
    State == State.DataLoaded
    it returns the Day before the Chart Time frame (if the time frame is set to 5 Days it returns the Date 6 day before).
    If GetPreviousTradingDayEnd is called in
    Code:
    OnBarUpdate
    , it starts with the Day before the Time frame and counts up to the last trading day.

    So where do i have to call GetPreviousTradingDayEnd or how can i ensure that if i call it, it really returns the last day and dont need a few iterations to count up to the last day ?

    Im using NinjaTrader 8 and NinjaTrader Continuum demo datafeed.
    Use Historical?


    Comment


      #3
      Hello NovaPrime,

      Thanks for your post.

      If you only need to get the previous day from the current day then member sledge has provided a good idea, (although the link is to NT7). The idea being to check what state you are in or not in.

      You can do something like:
      Code:
      if (State != State.Realtime) return;
      DateTime previousEndDate = TradingHours.GetPreviousTradingDayEnd(Time[0]);        
      Print(string.Format("The current bars date is {0} - the previous trading session ended on {1}", Time[0], previousEndDate));

      Comment


        #4
        Thank you very much, now it works as expected

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        79 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        45 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        29 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        32 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        66 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X