I'm looking to run one of my strategies between Midnight and 10:00 AM, shut down, then run again after 5:00 PM. I'm struggling with the paramaters for this because there is no "or" option in the conditions and every time I try to set up groups, it only seems to recognize one set of instructions. Is there an easy way to do this in strategy builder?
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
Prevent Strategy from Running During Specific Hours
Collapse
X
-
Prevent Strategy from Running During Specific Hours
Hi there,
I'm looking to run one of my strategies between Midnight and 10:00 AM, shut down, then run again after 5:00 PM. I'm struggling with the paramaters for this because there is no "or" option in the conditions and every time I try to set up groups, it only seems to recognize one set of instructions. Is there an easy way to do this in strategy builder?Tags: None
-
Hello koyunbaba, thanks for your question.
There is an Or (||) option in the builder. On the top left of the set, there is a setting "If all" or "If any" If all acts as the AND and If any acts as the OR. To do this set the main set to "if any" and make two condition groups set to "if all". You would enter the two time constraints into those two groups.
Please let me know if I can assist any further.
Chris L.NinjaTrader Customer Service
-
Thanks for your reply. I guess what I mean is that I'm struggling to combine the AND with the OR. So logically what I'm looking for is this:
IF <Indicator condition> >= X
AND (Current Bar Time of Day > 12:00 AND Current Bar Time of Day < 08:00)
OR (Current Bar Time of Day > 17:00 AND Current Bar Time of Day <=23:59)
The group function allows me to select an If Any operator, but then it doesn't truly filter the time - it only looks to the < or > to determine if the bar meets the criteria, which it always does.
Comment
-
Hi Koyunbaba,
I am not a support representative from Ninja Trader but I would like to help you with your question.
It looks like you are using the Strategy Builder and you want to be able to group conditions. It can be easily achieved, all you have to do is use the button "group" and play with it.
Let's say that you want to build this condition:
If (SMA(14) >= EMA(14) OR (Close > Open AND Time > 9:30 AM))
All you have to do in Conditions and Actions is at the upper left corner select "If Any" -which actually means OR- and configure the first part, which is "SMA(14) >= EMA(14)", then you need to create a grouped condition, so you click the "group" button, between "add" and "edit" buttons at the bottom right corner of Conditions. Here you will choose "If All" -which means AND- and configure the other 2 conditions.
To facilitate your understanding I included a picture that should give you a clue about how to do it, please check it out:
Comment
-
Hi koyunbaba, thanks for posting that.
I went ahead and made a working example that satisfies both of the time conditions. Please see attached. I removed your script in case you wanted to keep that private.
Please let me know if I can assist any further.Attached FilesChris L.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SantoshXX, Today, 03:09 AM
|
0 responses
11 views
0 likes
|
Last Post
by SantoshXX
Today, 03:09 AM
|
||
Started by DanielTynera, Today, 01:14 AM
|
0 responses
2 views
0 likes
|
Last Post
by DanielTynera
Today, 01:14 AM
|
||
Started by yertle, 04-18-2024, 08:38 AM
|
9 responses
41 views
0 likes
|
Last Post
by yertle
Today, 01:00 AM
|
||
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
12 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM |
Comment