NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-12-2012, 05:47 PM   #1
Jellybean
Member
 
Join Date: Apr 2012
Location: New Zealand
Posts: 58
Thanks: 14
Thanked 0 times in 0 posts
Default ExitOnClose Order Rejected

Hi

I'm trying to understand why the order produced by ExitOnClose was rejected. I would like suggestions for what I should investigate.

The strategy opened a short position with EnterShortStop().
Take profit and Stop loss orders were placed after entry fill.
ExitOnClose = true and ExitOnCloseSeconds = 660 (11 mintues).
The normal exits have been working fine.
ExitOnClose has tested OK on a demo account, but this is the first time ExitOnClose was required to close the position on a live account.

In this case the error stated "The order type is not allowed for the commodity affected Order" BuyToCover 1 Market"
However, the stop loss and take profit executions are also BuyToCover and work fine.

The account is with AMP / CQG.
PC time is set to New Zealand local time.

Cheers
Tony

Here is a section of the log:
13/09/2012 7:49:00|1|128|Exit on close handling for strategy 'Gap11' started. 13/09/2012 7:49:00|1|32|Order='1923921760/86497!AMP!ac86497' Name='Profit target' New state=PendingCancel Instrument='TF 09-12' Action=BuyToCover Limit price=838.2 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='1923921761/86497!AMP!ac86497' Name='Stop loss' New state=PendingCancel Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=846.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='2cd16e0faa39460e9051079c3d19df 28/86497!AMP!ac86497' Name='Exit on close' New state=PendingSubmit Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='2cd16e0faa39460e9051079c3d19df 28/86497!AMP!ac86497' Name='Exit on close' New state=Rejected Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=OrderRejected Native error='The order type is not allowed for the commodity' 13/09/2012 7:49:00|0|32|AMP Live, The order type is not allowed for the commodity affected Order: BuyToCover 1 Market 13/09/2012 7:49:00|0|128|Strategy 'Gap11/cd7055f2e7e749b88edcb152c9347629' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself. 13/09/2012 7:49:00|1|32|Order='1923921760/86497!AMP!ac86497' Name='Profit target' New state=Cancelled Instrument='TF 09-12' Action=BuyToCover Limit price=838.2 Stop price=0 Quantity=1 Type=Limit Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='1923921761/86497!AMP!ac86497' Name='Stop loss' New state=Cancelled Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=846.5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='6322db98c24042799b6ed63707aca5 8f/86497!AMP!ac86497' Name='Close' New state=PendingSubmit Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error='' 13/09/2012 7:49:00|1|32|Order='6322db98c24042799b6ed63707aca5 8f/86497!AMP!ac86497' Name='Close' New state=Rejected Instrument='TF 09-12' Action=BuyToCover Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=OrderRejected Native error='The order type is not allowed for the commodity' 13/09/2012 7:49:00|0|32|AMP Live, The order type is not allowed for the commodity affected Order: BuyToCover 1 Market 13/09/2012 7:49:00|1|128|Disabling NinjaScript strategy 'Gap11/cd7055f2e7e749b88edcb152c9347629'
Jellybean is offline  
Reply With Quote
Old 09-13-2012, 03:37 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,393
Thanks: 252
Thanked 968 times in 951 posts
Default

Hi Tony, which TIF setting were you using for this strategy for the market order on TF?
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 09-13-2012, 03:24 PM   #3
Jellybean
Member
 
Join Date: Apr 2012
Location: New Zealand
Posts: 58
Thanks: 14
Thanked 0 times in 0 posts
Default ExitOnClose Order Rejected

Hi Bertrand

TIF in strategy settings is GTC.

In the strategy code, for a short position:
Entry order is: EnterShortStop( 0, true, nContracts, entryLevel, entryName ); // GTC, worked OK
Take profit order is: SetProfitTarget( entryName, CalculationMode.Price, target ); // GTC, I think
Stop loss order is: SetStopLoss( entryName, CalculationMode.Price, stopLoss, false ); // GTC, I think
The rejected order was generated by Exit On Close handling. I don't know what TIF is set for this.

The strategy generated orders seem fine, it's the order generated by the exit on close handling that was rejected for being an order type that is not allowed.

I hope this helps, but let me know what else I can do.

Cheers
Tony
Jellybean is offline  
Reply With Quote
Old 09-13-2012, 03:55 PM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,777
Thanks: 158
Thanked 565 times in 556 posts
Default

GTC market orders are not supported on the TF /ICE exchange.

You will need to set your TIF to DAY at least for the market orders.

TimeInForce = Cbi.TimeInForce.Day;
NinjaTrader_Matthew is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Matthew for this post:
Old 09-13-2012, 04:18 PM   #5
Jellybean
Member
 
Join Date: Apr 2012
Location: New Zealand
Posts: 58
Thanks: 14
Thanked 0 times in 0 posts
Default ExitOnClose Order Rejected

Hi Matthew

These little pieces of information are like gold! Thanks.

For my further understanding:

1. At the moment I do not set TimeInForce in the strategy code, but I will. In the meantime, is it OK to set the Time in force = Day in the strategy settings on the chart?
2. At the moment in the strategy code, the entry orders use liveUntilCancelled = true. I presume I can I leave this as is, because they are not market orders. Right?

To help me avoid similar issues in the future, where can I find this kind of information without bugging you guys?

Thanks again.
Tony
Jellybean is offline  
Reply With Quote
Old 09-14-2012, 03:49 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,393
Thanks: 252
Thanked 968 times in 951 posts
Default

Yes, setting the TIF manually as strategy parameter would be fine - as an alternative - http://www.ninjatrader.com/support/h...imeinforce.htm

liveUntilCancelled is fine, with a TIF of DAY those would be cancelled with the session end handling as well.

We don't feel bugged at all, so just post or email when you need something.
NinjaTrader_Bertrand is online now  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
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
Cancel all pending order with ExitOnClose Czarek Automated Trading 1 11-09-2011 06:46 AM
When placing order NT shows order rejected for security reason djboon ATM Strategies (Discretionary Trading) 0 07-19-2011 04:00 AM
Error: Order rejected for reason: Pending live orders affected order... neoikon ATM Strategies (Discretionary Trading) 1 05-24-2010 09:04 AM
Submit Market Order if Stop Order Was Rejected (FOR DLL??) geoMEAN Automated Trading 6 11-12-2009 04:33 AM
06/05/2009 2:59:19 PM Order Order rejected - reason:Too late to replace order (201) junkone Strategy Development 1 05-06-2009 02:29 PM


All times are GMT -6. The time now is 03:53 AM.