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));
      Paul H.NinjaTrader Customer Service

      Comment


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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, Today, 10:57 PM
        0 responses
        2 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Today, 09:29 PM
        0 responses
        7 views
        0 likes
        Last Post Belfortbucks  
        Started by zstheorist, Today, 07:52 PM
        0 responses
        7 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        151 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Working...
        X