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
Strategy Builder variable reference
Collapse
X
-
Strategy Builder variable reference
I have created an entry strategy in Builder where one of the conditions refers to a set of conditions that occur during premarket hours. See images below. For some reason the premarket filter is not screening the entries and gives me entries regardless of the PreMktCriteria being = 1. I may be missing something? Please advice. Thank you any suggestions welcomed.
Tags: None
-
Hi Jesse, I tried changing to 0 same issue. I also tried bool as in image 01 default as "PreMktCriteria bool false" with no change.
Comment
-
Hello designer01,
You will need to use a Print as an action to better understand when your condition is becoming true.
the way the condition is set up would work as the following:
Set 1: checks for a time range and HMA condition, if true it sets the variable to 1
Set 2: checks the HMA condition and if the variable equals 1, if true enters.
Once your set 1 becomes true once then the set 2 will be allowed any time going forward. If you meant to prevent entries in any other use case then you still need to add other logic to do that. You can reset the variable back to 0 when the condition should no longer be allowed.
An example of what may be happening could be that on a historical day the variable is set to true, then all future days the variable is still true leading to set 2 being checked all the time. You would have to make an additional set if the strategy runs more than 1 day to reset that variable on the first bar of the session.
JesseNinjaTrader Customer Service
Comment
-
Hi Jesse, Thanks I had to unlock the code and insert an else statement and it works.
I could not figure out how to do it in Builder, is there an option for an else statement in Builder see code below.
Code:// Set 1 if ((Times[0][0].TimeOfDay > new TimeSpan(9, 29, 0)) && (Times[0][0].TimeOfDay < new TimeSpan(9, 31, 0)) && (Close[0] > HMA1[0])) { BackBrush = Brushes.SandyBrown; PreMktCriteria = true; } else if ((Times[0][0].TimeOfDay > new TimeSpan(9, 29, 0)) && (Times[0][0].TimeOfDay < new TimeSpan(9, 31, 0)) && (Close[0] < HMA1[0])) { PreMktCriteria = false; }
Comment
-
Hello designer01,
There is not an option for an else statement in the builder. The alternative would be to make an always true set which comes before the first condition.
For example set 1 would set PreMktCriteria to false with no conditions or with a different set of hours to check. In set 2 you can check the condition which sets it to true. That would leave it false for all bars where set 2 is not true. This of course depends on your overall goal and how that PreMktCriteria variable should operate.JesseNinjaTrader Customer Service
Comment
-
Hi Jesse, I did 2 separate if statements sets as shown in the code above, no need to have the else as you said. Works good. Thanks
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by StockTrader88, 03-06-2021, 08:58 AM
|
45 responses
3,991 views
3 likes
|
Last Post Today, 09:51 AM | ||
Started by TAJTrades, Today, 09:46 AM
|
0 responses
7 views
0 likes
|
Last Post
by TAJTrades
Today, 09:46 AM
|
||
Started by rhyminkevin, Yesterday, 04:58 PM
|
5 responses
62 views
0 likes
|
Last Post
by dp8282
Today, 09:36 AM
|
||
Started by realblubb, Today, 09:28 AM
|
0 responses
8 views
0 likes
|
Last Post
by realblubb
Today, 09:28 AM
|
||
Started by AaronKoRn, Yesterday, 09:49 PM
|
1 response
19 views
0 likes
|
Last Post
by Rikazkhan007
Today, 09:24 AM
|
Comment