Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stop Orders being cancelled at close of the bar
Collapse
X
-
Hello WalterSkinner,
Thanks for your post.
Here is an example of it being resubmitted:
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLongStopMarket(your parameters here); // resubmit on each OnBarUpdate().
}
"I'm having an issue where doing this pulls the stop back, the trail logic moves it again, and then the re-submission pulls it back again."
You would need to control your logic with bool variables to prevent that situation. You would encapsulate your stop logic with the true condition of Position.MarketPosition == MarketPosition.Long (or short) to ensure it is updated.
Last edited by NinjaTrader_ChelseaB; 03-22-2022, 10:56 AM.
- Likes 1
-
Hi Chelsea,Originally posted by NinjaTrader_ChelseaB View PostHello juannoguerol,
Re-submit orders on each new bar to keep them alive when not using the IsLiveUntilCancelled overload parameter (which defaults to false), or use IsLiveUntilCancelled as true to keep the order alive.
To understand when orders are being are being automatically cancelled use TraceOrders.
https://ninjatrader.com/support/help...raceorders.htm
Can you point me to an example of ExitLongStopMarket/ExitShortStopMarket being re-submitted?
I'm having an issue where doing this pulls the stop back, the trail logic moves it again, and then the re-submission pulls it back again.
Frustrating thing is I had this working on some old code that got overly complex, so now I'm trying to simplify things but it's breaking.
I had changed from this type of stop (ExitLongStopMarket) to SetStopLoss while trying to reduce complexity but that brought an entirely different issues so I'm going with the one I've had success with in the past.
Leave a comment:
-
Hello juannoguerol,
Re-submit orders on each new bar to keep them alive when not using the IsLiveUntilCancelled overload parameter (which defaults to false), or use IsLiveUntilCancelled as true to keep the order alive.
To understand when orders are being are being automatically cancelled use TraceOrders.
Leave a comment:
-
Well, after a little digging and testing out for a while, I think I finally figured out how to solve my own problem.
For anybody interested:
- By default a simple stop orders get cancelled at the next bar close (something I did not know).
- You have to create a more "advanced" order that has a setting called "IsLiveUntilCancelled" set to true. You can check it out here - https://ninjatrader.com/support/help...rlonglimit.htm
- Then you have to do some order handling and cancel those orders if not executed (after a period of time, bars, or whatever method you want to use). You can check it out here - https://ninjatrader.com/support/help...r_handling.htm
Peace.
- Likes 4
Leave a comment:
-
Stop Orders being cancelled at close of the bar
Hello all,
I've been struggling to place my stop orders in my strategy for a bit, so decided to post this up and ask the pros for some guidance.
I have a strategy that places a Stop Order at the HH/HL (Swing), each time there is a new swing the strategy places a new Stop Order at the new level. The problem I'm having is that if the price does not reach that level within the next bar after the level has been set, the order seems to get cancelled. I would like for the Stop Order to remain in place at the Swing High price level until it gets triggered or there is a new Swing High and move the order to the new price. I'm printing a green diamond to check if the swing is being detected at the correct time, and also placed at the desired price (swing high + tick). I would also like to clarify that this is a Long setup only, no short orders are being placed anywhere.
Screenshot and code below, any help would be much appreciated.
---
TimeInForce = TimeInForce.Gtc;
---
I'm detect the new swing high by comparing it with the previous - the lookback is set to (4). Then place the stop order at the swing price + 1 tick, draw diamond at the same price level.
if (Swing1.SwingHigh[5] != Swing1.SwingHigh[0])
{
EnterLongStopMarket(Convert.ToInt32(DefaultQuantit y), (Swing1.SwingHigh[0] + (1 * TickSize)) , "long" + CurrentBar); // STOP ORDER AT SWING
Draw.Diamond(this, "LongDiamond" + CurrentBar, true, 0, (Swing1.SwingHigh[0] + (1 * TickSize)) , Brushes.Green); // DRAW DIAMOND AT SWING
}1 PhotoTags: None
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by kinfxhk, 07-14-2026, 09:39 AM
|
0 responses
21 views
0 likes
|
Last Post
by kinfxhk
07-14-2026, 09:39 AM
|
||
|
Started by kinfxhk, 07-13-2026, 10:18 AM
|
0 responses
60 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 10:18 AM
|
||
|
Started by kinfxhk, 07-13-2026, 09:50 AM
|
0 responses
43 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 09:50 AM
|
||
|
Started by kinfxhk, 07-13-2026, 07:21 AM
|
0 responses
47 views
0 likes
|
Last Post
by kinfxhk
07-13-2026, 07:21 AM
|
||
|
Started by kinfxhk, 07-11-2026, 02:11 AM
|
0 responses
38 views
0 likes
|
Last Post
by kinfxhk
07-11-2026, 02:11 AM
|

Leave a comment: