Trying to use strategy wizard to define an exit strategy to an entry. From my initial entry if market goes against me 3 bars. Then Exit. Any Ideas on how to do that.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Define Exit Conditions for a strategy,
Collapse
X
-
Define Exit Conditions for a strategy,
Hello All,
Trying to use strategy wizard to define an exit strategy to an entry. From my initial entry if market goes against me 3 bars. Then Exit. Any Ideas on how to do that.Tags: None
-
-
Hello traderfolife777,
Thank you for your inquiry.
Here is an example below that will exit if three bars go against you in a long position:
Can you please provide clarification on your second post? Are you wanting to exit if three bars go in your favor as well?Code:When the following conditions are true: (add these conditions) (symbols in brackets denote what to select in the middle column) Strategy -> Current market position [==] Strategy -> Long Misc -> Bars since entry [==] Misc -> Numeric value -> Parameters/Value = 3 Price data -> Close -> Parameters/Bars ago = 0 [<] Price data -> Close -> Parameters/Bars ago = 1 Price data -> Close -> Parameters/Bars ago = 1 [<] Price data -> Close -> Parameters/Bars ago = 2 Price data -> Close -> Parameters/Bars ago = 2 [<] Price data -> Close -> Parameters/Bars ago = 3 Do the following: (add this condition) Order management -> Exit long position
Zachary G.NinjaTrader Customer Service
Comment
-
IF I am short market goes in my favor 6 candles for example then goes back up 3 candles then I want to be out at the close of the third..Is the logic for that similar to what you wrote above.
Comment
-
Hello traderforlife777,
The logic would be similar.
I would suggest using a User Defined Variable that will keep track if a condition you have created is true or not, and using that variable, determine if another set of code will execute.
Example:
Code:Set 1 When the following conditions are true: (add these conditions) (symbols in brackets denote what to select in the middle column) Strategy -> Current market position [==] Strategy -> Short Price data -> Close -> Parameters/Bars ago = 0 [<] Price data -> Close -> Parameters/Bars ago = 1 Price data -> Close -> Parameters/Bars ago = 1 [<] Price data -> Close -> Parameters/Bars ago = 2 Price data -> Close -> Parameters/Bars ago = 2 [<] Price data -> Close -> Parameters/Bars ago = 3 Price data -> Close -> Parameters/Bars ago = 3 [<] Price data -> Close -> Parameters/Bars ago = 4 Price data -> Close -> Parameters/Bars ago = 4 [<] Price data -> Close -> Parameters/Bars ago = 5 Price data -> Close -> Parameters/Bars ago = 5 [<] Price data -> Close -> Parameters/Bars ago = 6 Do the following: (add this condition) Misc -> Set user defined variable -> Parameters/Variable = Variable0 and Parameters/Value = 1 Set 2 When the following conditions are true: (add these conditions) (symbols in brackets denote what to select in the middle column) User variables -> Variable 0 [==] Misc -> Numeric value -> Parameters/Value = 1 Price data -> Close -> Parameters/Bars ago = 0 [>] Price data -> Close -> Parameters/Bars ago = 1 Price data -> Close -> Parameters/Bars ago = 1 [>] Price data -> Close -> Parameters/Bars ago = 2 Price data -> Close -> Parameters/Bars ago = 2 [>] Price data -> Close -> Parameters/Bars ago = 3 Do the following: (add these conditions) Order management -> Exit short position Misc -> Set user defined variable -> Parameters/Variable = Variable0 and Parameters/Value = 0
Zachary G.NinjaTrader Customer Service
Comment
-
need your help
One More thing... by the way your information is helpful.
Building logic:-
Looking to build a short logic to enter a trade on a reversal candle after price penetrated SMA moving average.
Short Scenario:
Close 1>Close 3
Price has moved up and touched or penetrated SMA 50.
price Reversed and closed under the SMA 50 within 2 candles since the price penetration.
Then Executed the short- entry market.
Having a hard time coming up with a logic on market wizard to do this.
Also, Is it possible to have a trailing stop along with multiple exit conditions . will that lead to conflict and multiple orders to exit sent then error message and strategy disabled.
Comment
-
Hello traderforlife777,
Here are some tips:
You could use the CrossAbove or CrossBelow in the middle column when adding conditions to check if the closing price has crossed above or below the SMA.
You could use a user defined variable to keep track of how many bars have elapsed since the cross over by incrementing it by 1 each time a bar has passed.
Example:
Then check to see if the closing price is below the SMA and the Variable0 was a number from 0 - 2 (checking to see if the closing price has been below the SMA value within 2 bars)Code:Misc -> Set user defined variable -> Parameters/Value = Variable0 + 1 (increments Variable0 by 1)
Example:
A trail stop order is automatically cancelled if the managing position is closed by another strategy generated exit order, so you shouldn't have any conflicts.Code:User variables -> Variable0 [<] Misc -> Numeric value -> Parameters/Value = 3 Price data -> Close [<] Indicators -> SMA -> Parameters/Period = 50
Zachary G.NinjaTrader Customer Service
Comment
-
need your help
I am trying to build a condition in strategy wizard:
Long:
LOW of candle [< or =] 50 SMA then that same candle closes[>] 50 SMA.
Send market order to buy at the close of that (Trigger Candle).
If candle closes under the 50 SMA then NO Trade.
What would be the logic for that.
If I calculate the strategy at the close of each bar would that be an issue if I want to see a price behavior that is intra candle..
Let me know if this is making any sense to you.
All the information below is invaluable.
Thank you
george
Comment
-
Hello traderfolife777,
Unfortunately, this would go beyond the realms of using the Strategy Wizard and would require custom coding.
I would suggest looking at the Educational Resources section of the NinjaScript section of our help guide for helpful information as a good starting off point: http://ninjatrader.com/support/helpG..._resources.htm
Please, let us know if we may be of further assistance.Zachary G.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
68 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
24 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
27 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
53 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment