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
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
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.Paul H.NinjaTrader Customer Service
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
94 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
6 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 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