NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 01-25-2011, 05:17 AM   #1
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default Orders rejected by broker due to order sequence?

In the last few weeks, I have been running into a problem with order rejections from my broker (MBTrading). In discussions with them, it seems to be happening when my strategy tries to reverse a position. The sequence of order submission is placing the new position entry order BEFORE closing the previous position. In my case, I keep a minimum balance and having my pending orders basically doubled/tripled in size triggers a rejection and then disables my strategy.

As part of this event, I also get a note from NT that an overfill has occured.

Any suggestions?

Thanks.
Last edited by billr; 01-25-2011 at 05:21 AM.
billr is offline  
Reply With Quote
Old 01-25-2011, 06:34 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Bill, overfills usually occur when trading too close to the inside market with multipe working orders changing state - http://www.ninjatrader.com/support/h...d_approach.htm - think of it like the inflight execution concerns.

For the reverse issue with MBT - does it only happen when you're Long?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-25-2011, 06:40 AM   #3
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

Not sure. this time is was from a long position trying to close and go short.

I don't know enough about the unmanaged topic to understand your reference. Sorry. It is something I can fix without going to unmanaged programming?
billr is offline  
Reply With Quote
Old 01-25-2011, 08:36 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

What method sequence are you using? On long equity positions, you for example can't submit an ExitLongLimit() followed by an ExitLongStop() as the second order will be rejected since MBT tags it as an order to reverse your position, the same applies to using SetProfitTarget() and then later on using SetStopLoss().

You do not have to go unmanaged, this link just provides a discussion of the topic of overfills and how to address it - you would need to review the sequence of events leading to the overfill to be able to understand how to improve the strategy. Unmanaged would just provide finer options here for you to selfhandle this situation in code.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-25-2011, 03:26 PM   #5
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

Oh, I didn't know that about the SetProfitTarget and SetStopLoss issue. I have a strategy that uses SetProfitTarget and SetStopLoss initially, then may move StopLoss to new level as Position Profits hit targets. Sort of a very basic version of a one step trailing stop. Could that be causing this?

Thanks Bertrand.
billr is offline  
Reply With Quote
Old 01-25-2011, 04:19 PM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hi Bill,

Yes, it can happen when there are several working orders close to the market. As part of your stop loss modification, you may consider adjusting the remaining profit target so that both orders aren't near the market.

Make sure also that your profit targets and stop losses refer to a specific fromEntrySignal.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 01-25-2011, 04:27 PM   #7
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

The problem with that is by definition, reversing a position includes several orders that are close to market. If I send you my ninja script, can you tell me whether you see this problem inherent in how my positions are entered?

If not, do you have an example of how to handle closing an open position and entering a new position when strategy wants to reverse an open position?

I am not well versed enough in NS to try implementing an unmanaged state.

Thanks.
billr is offline  
Reply With Quote
Old 01-26-2011, 08:45 AM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Bill, we could take a look at your trace / logs to help you understand what's happening, unfortunately we would not be able to debug / modify the code - overfills and in-flight executions are an inherent risk in electronic trading, for best ways to address them through code the unmanaged mode needs to be used, as it could ignore overfills coming in so the strategy is then not shutdown as part of the strategy error handling.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-26-2011, 08:55 AM   #9
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

I understand you can't de-bug. But I would like to sent you logs/trace to see what you think.
billr is offline  
Reply With Quote
Old 01-26-2011, 09:30 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

Sure, I just got them and will take a look into.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2011, 10:43 AM   #11
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

Bertrand, did you ever get a chance to check my logs/trace to see what might have been happening?
Thanks.
billr is offline  
Reply With Quote
Old 02-10-2011, 11:02 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

I believe so and replied to your email - have you checked your inbox? If not, please let me know and I'll try to resend it.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2011, 11:13 AM   #13
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

I don't think I received that email, or accidentally deleted it. (It was the same time you and I had discussed my ranting about MBT, so I may have been mixing them up with delete??

So if you still have it, a re-send would be appreciated.
Thanks.
Bill
billr is offline  
Reply With Quote
Old 02-10-2011, 11:28 AM   #14
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

o worries, will see if I can find it still and resend to you.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 02-10-2011, 02:51 PM   #15
billr
Senior Member
 
Join Date: Apr 2010
Location: San Antonio, Texas
Posts: 315
Thanks: 31
Thanked 2 times in 2 posts
Default

Quote:
...for example can't submit an ExitLongLimit() followed by an ExitLongStop() as the second order will be rejected since MBT tags it as an order to reverse your position, the same applies to using SetProfitTarget() and then later on using SetStopLoss().
Could you explain why the SetProfitTarget and SetStopLoss cannot be used? Thanks.
billr is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Order rejected for reason: Pending live orders affected order... neoikon ATM Strategies (Discretionary Trading) 1 05-24-2010 09:04 AM
unrecognized escape sequence due to a "\" tinkerz General Programming 1 03-11-2010 10:13 AM
Rejected Order - Sell stop limit orders can't be placed.... TradingDreamer General Programming 4 12-09-2009 06:59 AM
Orders rejected as violating default order settings tooearly Strategy Development 7 06-30-2009 10:25 AM
Use keyboard keys (or sequence) to enter orders DoveforUsAll ATM Strategies (Discretionary Trading) 3 01-22-2006 03:14 PM


All times are GMT -6. The time now is 03:31 PM.