In my indicator code, I need to add a logic to check for Holiday and Weekends for given date. How to do that ? I need your help.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to check that a datetime is Holiday or Weekend ?
Collapse
X
-
Chelsea B.NinjaTrader Customer Service
-
Hello nandhumca,
The second link is how to find holidays. Did you copy the code from the help guide into a script test and found the resulting print is insufficient?
You can compare the holiday.Date to any other DateTime object.
If you mean you don't want to follow the holidays set in the TradingHours template, you want some custom C# code that arbitrarily lists holidays in your part of the world, this would be something you have to custom build.
Below is a link to a google search of 'C# date is holiday' which returns some pretty good results.
Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea,
I tried to see what values it holds. It is not listing all the Holidays . Below is the output.
[12/25/2015 12:00:00 AM, Christmas Day]Code:foreach(KeyValuePair<DateTime, string> holiday in TradingHours.Holidays) { Print(holiday); }
[1/1/2016 12:00:00 AM, New Year's Day]
[3/25/2016 12:00:00 AM, Good Friday]
[12/26/2016 12:00:00 AM, Christmas Day]
[1/2/2017 12:00:00 AM, New Year's Day]
[4/14/2017 12:00:00 AM, Good Friday]
[12/25/2017 12:00:00 AM, Christmas Day]
[1/1/2018 12:00:00 AM, New Year's Day]
[3/30/2018 12:00:00 AM, Good Friday]
[12/25/2018 12:00:00 AM, Christmas Day]
[1/1/2019 12:00:00 AM, New Year's Day]
[4/19/2019 12:00:00 AM, Good Friday]
[12/25/2019 12:00:00 AM, Christmas Day]
[1/1/2020 12:00:00 AM, New Year's Day]
[4/10/2020 12:00:00 AM, Good Friday]
[12/25/2020 12:00:00 AM, Christmas Day]
[1/1/2021 12:00:00 AM, New Year's Day]
[12/24/2021 12:00:00 AM, Christmas Eve]
Comment
-
Hello nandhumca,
This would be in the Central time zone for the exchange. I am seeing an early close for 11/26 2015 in the screenshot (showing you have not modified this) which is a Thursday.
What date and time is 11/25 at 12:00 when converted to the central time zone?
There will be no trading during the full and partial holidays during the time listed in the TradingHours template.
You can get the list of full holidays by looping through TradingHours.Holidays. You can get the list of partial holidays by looping through TradingHours.PartialHolidays. You can loop through both to get both.Last edited by NinjaTrader_ChelseaB; 08-30-2021, 12:40 PM.Chelsea B.NinjaTrader Customer Service
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment