Buy at market opening 1st minute bar price +20 pts and simultaneously have a one cancels other order(OCO) to sell at 1st minute opening bar -20pts?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Condition builder help
Collapse
X
-
Condition builder help
I've managed this:
Set Variable0 to Open Price of Opening Time bar + Price 20
Set Enter Long with Stop/Limit when bar Close Price == Variable0
Set Variable1 to Open Price of Opening Time bar - Price 20
Set Enter Short with Stop/Limit when bar Close Price == Variable1
How do I get one trade to cancel the other when it triggers?
I'm looking at 'Order methods' in Help File.
-
Condition builder help
This might work I'm thinking(need to test):
When Variable0 matches price and Long position is triggered then set Variable1 to 0 so it can never match Price on future bars until it moves to next day and resets/initialises again at Opening Time.
Comment
-
Hello Shambo,
Welcome to our forums.
The main difficulty here is that you'll be running into NinjaTrader's internal order handling rules.
Methods that generate orders (excluding market orders) to enter a position will be ignored if:- A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
- A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
- The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
OCO functionality can be achieved by working with IOrder objects and checking order states.
Ryan M.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Mindset, 04-21-2026, 06:46 AM
|
0 responses
117 views
0 likes
|
Last Post
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
166 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
85 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
130 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
88 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment