Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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 inanazsocial, Today, 01:15 AM
|
1 response
5 views
0 likes
|
Last Post Today, 02:18 AM | ||
Started by rocketman7, Today, 02:12 AM
|
0 responses
6 views
0 likes
|
Last Post
by rocketman7
Today, 02:12 AM
|
||
Started by dustydbayer, Today, 01:59 AM
|
0 responses
1 view
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
23 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
Comment