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 sofortune, Today, 10:28 AM
        3 responses
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by DawnTreader, 05-08-2024, 05:58 PM
        11 responses
        41 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by tkaboris, Today, 06:27 AM
        4 responses
        13 views
        0 likes
        Last Post tkaboris  
        Started by marcus2300, Today, 10:21 AM
        2 responses
        4 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by proptradingshop, Today, 10:07 AM
        3 responses
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X