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 FrazMann, Today, 11:21 AM
        0 responses
        3 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        10 responses
        36 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        24 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X