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
How to compare two conditions?
Collapse
X
-
Hello relogical,
Thanks for your post.
This can be done in the strategy builder. You would need to create two double-type variables to store the value of the current cross and the previous cross (I would suggest using the MACD .Avg as the value to save). Set the default value of these to 0. You will also need a bool variable to indicate when cross is found, set the default to false.
In one set you would check for the cross condition and when true, save the value of the cross into the variable representing the current cross. You would also set the bool true.
In a 2nd set, you would check that the cross found bool is true and that the current cross variable is less than or equal to the previous cross variable. When these two conditions are true you would assign the current cross variable to the previous cross variable and set the bool to false. So this set reacts to when the cross is less than or equal to the previous one and saves the current into the previous.
In a 3rd set, you would check to see if the cross found bool is true and that the current cross variable is greater than the previous cross variable. When these two conditions are found you have your entry condition, you would also need to set the bool to false and to save the current cross variable into the previous cross variable This is your entry set.
Last edited by NinjaTrader_PaulH; 01-27-2022, 07:37 AM.Paul H.NinjaTrader Customer Service
- Likes 1
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,403 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
7 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment