how do i write the code to let the long trade reach the profit target, without the short trade activating while in a long trade. and the other way around. thanks
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
short trade activates during long trade active
Collapse
X
-
Hello bizzz10,
Thanks for your post.
Entry orders in the opposite direction will automatically close existing position and then enter additional order(s) to achieve the new direction.
To prevent this action, you can add the entry order condition that checks to see if the current market position is flat before placing the order.
For example:
if (your condition(s) to enter && Position.MarketPosition == MarketPosition.Flat)
{
// order entry
}
Reference: https://ninjatrader.com/support/help...etposition.htm
Note, if you are using the NinjaTrader 7 strategy wizard, on the left side of the condition builder select Strategy>Current market position, in the center select == , on the right side select Strategy>Flat.
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
566 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
547 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment