Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identify last trading day of the week

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

    Identify last trading day of the week

    Is there any function to identify last trading day of the week? I need it when week is short due to holidays, so the last trading day is Thursday.

    #2
    Hello nysetrader,
    Thanks for your post and I am happy to assist you.

    There are no functions to determine the last trading week, but to know the day of the week you can use the DayOfWeek enum:

    Code:
    if (Time[0].DayOfWeek = DayOfWeek.Thursday)
    {  // do something  }
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you.
      I know how to know the day of week, but I need to know if it last trading day of the week or not.

      Comment


        #4
        Hello nysetrader,
        Unfortunately there are no native functions for it. You can however hard code the specific days and compare it. Say if 18th and 26th are the date you are looking for then hard code the date in an array and look if the bar date matches it or not

        in variable:
        Code:
        DateTime[] holidays = {new DateTime(2012,4,18), new DateTime(2012, 4, 26)};
        in OnBarUpdate
        Code:
        if (Time[0].Date == holidays[0] || Time[0].Date == holidays[1])
        {  // do something }

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        59 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        143 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        283 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X