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 charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
47 views
0 likes
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
141 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
160 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|
||
|
Started by CarlTrading, 05-10-2026, 08:12 PM
|
0 responses
96 views
0 likes
|
Last Post
by CarlTrading
05-10-2026, 08:12 PM
|
||
|
Started by Hwop38, 05-04-2026, 07:02 PM
|
0 responses
275 views
0 likes
|
Last Post
by Hwop38
05-04-2026, 07:02 PM
|

Comment