Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Holidays algorithm
Collapse
X
-
Holidays algorithm
Hi guys! I want to write an algorithm that will manage the strategy during the holidays. I need to somehow get in a variable the hours and minutes of early closing and late opening. In order to then use this variable to close all orders and set a ban on opening deals 1 hour before stopping trading on a holiday. I have studied the reference manual (TradingHours.Holidays, TradingHours.PartialHolidays), but I cannot implement the algorithm. Tell me how to make this algorithm correctly. I would be grateful for the sample code. Thank.Last edited by Kostiantyn; 02-14-2021, 11:10 AM.Tags: None
-
Hello Kostiantyn,
The TradingHours.Holidays and TradingHours.PartialHolidays would be correct.
These provide a collection of dates of holidays.
You can check if the date of bar has the same date to know that the date of the bar is on a holiday by looping through the collection and comparing the date with the Time[0].Date.
A SessionIterator can be used if you want to know the time that session will end for that day, once you have determined the bar date is equal to the holiday date.
Use .AddHours(-1) to subtract an hour from a datetime or timespan.
Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services or one on one educational support over the phone in our NinjaScript Support department. This is so that we can maintain a high level of service for all of our clients as well as our associates.
That said, we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.
This thread will remain open for any community members that would like to write this script as a convenience for you.
You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.Chelsea B.NinjaTrader Customer Service
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
38 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
64 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment