So then NT disables and stops running the strategy. I guess what I would like to happen is if this scenario occurs, I would simply like to close the position. How can I accomplish this? What is your advice for this scenario?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Order Rejected
Collapse
X
-
Order Rejected
My order is being rejected during market replay I presume because the Market moving so quick.
So then NT disables and stops running the strategy. I guess what I would like to happen is if this scenario occurs, I would simply like to close the position. How can I accomplish this? What is your advice for this scenario?Tags: None
-
See this:Originally posted by reynoldsn View PostHow can I accomplish this? What is your advice for this scenario?
Then check for OrderState.Rejected in OnOrderUpdate(), and close position if found.Code:RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
Unfortunately, the popup message box from NinjaTrader cannot be disabled.
-
Your code running in market replay at 1x or 500x follows the same order of events and should work without issue.
So does it happen in 1x also?
Post some complete sample code that reproduces the problem and someone might be able to offer a fix/suggestion to your issue. There isn't enough to go on based on your post.
Comment
-
UPDATE:
Here is my abbreviated, pertinent code. Does it look like a correct implementation as far as handling order rejection?
My concern is that now I am using:
Are there other order problems I now need to manually check?Code:RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;
Thank you!
Code:private IOrder stopLossOrder = null; protected override void Initialize() { RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction; SetProfitTarget(sENTRY1L, CalculationMode.Ticks, _profitTarget); SetProfitTarget(sENTRY1S, CalculationMode.Ticks, _profitTarget); SetStopLoss(CalculationMode.Ticks, _stopLoss); //Init order objects iOrderL1 = null; iOrderS1 = null; EntriesPerDirection = 100; EntryHandling = EntryHandling.AllEntries; CalculateOnBarClose = true; } protected override void OnBarUpdate() { if (_takeTrade) { EnterShort(1, sENTRY1S); if (stopLossOrder == null) stopLossOrder = ExitShortStop(Position.AvgPrice + _stopLoss * TickSize); } } protected override void OnOrderUpdate(IOrder order) { if (stopLossOrder != null && stopLossOrder == order) { // Rejection handling if (order.OrderState == OrderState.Rejected) { // Stop loss order was rejected !!!! // Do something about it here Print("Order Rejected at: " + Time[0]); } } }
Comment
-
Looks like a good start.
Right after you detect the OrderRejected, say, after your Print,
exit your position and set your stopLossOrder to null.
I think RealTimeErrorHandling documentation says this variable
only deals with order rejected errors.
Overfill processing, for example, is controlled by a different variable,
called IgnoreOverFill.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment