• 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

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?


    https://ninjatrader.com/support/help...historical.htm

    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 Papercut110, Today, 09:08 PM
        0 responses
        2 views
        0 likes
        Last Post Papercut110  
        Started by iq200, 11-09-2019, 08:26 AM
        5 responses
        56 views
        0 likes
        Last Post koganam
        by koganam
         
        Started by johng964, Today, 02:57 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by spamula, Today, 03:00 PM
        2 responses
        16 views
        0 likes
        Last Post spamula
        by spamula
         
        Started by MARTIN MARTIN, Today, 01:01 PM
        0 responses
        16 views
        0 likes
        Last Post MARTIN MARTIN  
        Working...
        X