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
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
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
-
Originally posted by reynoldsn View PostHow can I accomplish this? What is your advice for this scenario?
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:
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 briansaul, Today, 05:31 AM
|
0 responses
2 views
0 likes
|
Last Post
by briansaul
Today, 05:31 AM
|
||
Started by fwendolynlpxz, Today, 05:19 AM
|
0 responses
4 views
0 likes
|
Last Post Today, 05:19 AM | ||
Started by traderqz, Yesterday, 12:06 AM
|
11 responses
28 views
0 likes
|
Last Post Today, 05:11 AM | ||
Started by PaulMohn, Today, 03:49 AM
|
0 responses
8 views
0 likes
|
Last Post
by PaulMohn
Today, 03:49 AM
|
||
Started by inanazsocial, Today, 01:15 AM
|
1 response
10 views
0 likes
|
Last Post Today, 02:18 AM |
Comment