NinjaTrader Support Forum  

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

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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-08-2011, 10:49 AM   #1
monpere
Senior Member
 
Join Date: Dec 2007
Posts: 310
Thanks: 0
Thanked 5 times in 3 posts
Default Error - Order on wrong side of market

My strategy enters trades in the following way, enter at market using EnterLong()/EnterShort(), place my stop/targets 10 ticks above/below the entry using SetStopLoss()/SetProfitTarget(), and does a custom trail by calling SetStopLoss() again.

Most of the time this strategy works fine, but once in a while the orders will get rejected and the strategy will terminate itself saying that one of my orders is on the wrong side of the market. Here is the data for one of these errors. The should have entered at market at 83.54, stop/target +/- 10 ticks. It got filled at 83.48 and the stop should have been at 83.38, target at 83.58, trail 12 ticks

Error:
"Sell stop or sell Stop limit orders can't be placed above the market. affected order: Sell 1 Stop @ 83.53"

Output Window:
########## New Trade (08Aug11 12:21:13) ##########
--- Started BuyMarketReverse
CL 09-11.122113 - BuyMarketReverse 1 @ 83.54 ---
>>> OrdeUpdate: Order='1109fd872ae34055880bbe6aefeeef3b/Sim101' Name='BuyMarketReverse
CL 09-11.122113' State=PendingSubmit Instrument='CL 09-11' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='1109fd872ae34055880bbe6aefeeef3b' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='1109fd872ae34055880bbe6aefeeef3b/Sim101' Name='BuyMarketReverse
CL 09-11.122113' State=Accepted Instrument='CL 09-11' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='1109fd872ae34055880bbe6aefeeef3b' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='1109fd872ae34055880bbe6aefeeef3b/Sim101' Name='BuyMarketReverse
CL 09-11.122113' State=Working Instrument='CL 09-11' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='1109fd872ae34055880bbe6aefeeef3b' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='1109fd872ae34055880bbe6aefeeef3b/Sim101' Name='BuyMarketReverse
CL 09-11.122113' State=Filled Instrument='CL 09-11' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=1 Fill price=83.48 Token='1109fd872ae34055880bbe6aefeeef3b' Gtd='1/1/0001 12:00:00 AM' <<<
Order Filled at: 83.48
>>> OrdeExecution: Execution='c6e90dae4c404858b8b527c224c4d254' Instrument='CL 09-11' Account='Sim101' Name='BuyMarketReverse
CL 09-11.122113' Exchange=Default Price=83.48 Quantity=1 Market position=Long Commission=0 Order='1109fd872ae34055880bbe6aefeeef3b' Time='8/8/2011 12:21:13 PM' <<<
>>> PositionUpdate <<<
### Standard Position Opened @ 83.4800
**NT** Strategy 'A0_TradeManager/f35c6b9b33db4301979131b11304ad4e' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
8/8/2011 12:21:13 PM CancelAllOrders: BarsInProgress=0
>>> OrdeUpdate: Order='06617919bf8740fd980194ccb86ebe58/Sim101' Name='Profit target' State=PendingSubmit Instrument='CL 09-11' Action=Sell Limit price=83.58 Stop price=0 Quantity=1 Type=Limit Tif=Gtc OverFill=False Oco='c6e90dae4c404858b8b527c224c4d254-827' Filled=0 Fill price=0 Token='06617919bf8740fd980194ccb86ebe58' Gtd='1/1/0001 12:00:00 AM' <<<
@@@ Long Trail to 83.36 < 83.48
8/8/2011 12:21:13 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Price Value=83.36 Currency=0 Simulated=False
8/8/2011 12:21:14 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='' Mode=Ticks Value=10 Currency=0 Simulated=False
8/8/2011 12:21:14 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=10 Currency=0 Simulated=False
>>> OrdeUpdate: Order='06617919bf8740fd980194ccb86ebe58/Sim101' Name='Profit target' State=Accepted Instrument='CL 09-11' Action=Sell Limit price=83.58 Stop price=0 Quantity=1 Type=Limit Tif=Gtc OverFill=False Oco='c6e90dae4c404858b8b527c224c4d254-827' Filled=0 Fill price=0 Token='06617919bf8740fd980194ccb86ebe58' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='06617919bf8740fd980194ccb86ebe58/Sim101' Name='Profit target' State=Working Instrument='CL 09-11' Action=Sell Limit price=83.58 Stop price=0 Quantity=1 Type=Limit Tif=Gtc OverFill=False Oco='c6e90dae4c404858b8b527c224c4d254-827' Filled=0 Fill price=0 Token='06617919bf8740fd980194ccb86ebe58' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='06617919bf8740fd980194ccb86ebe58/Sim101' Name='Profit target' State=PendingCancel Instrument='CL 09-11' Action=Sell Limit price=83.58 Stop price=0 Quantity=1 Type=Limit Tif=Gtc OverFill=False Oco='c6e90dae4c404858b8b527c224c4d254-827' Filled=0 Fill price=0 Token='06617919bf8740fd980194ccb86ebe58' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='06617919bf8740fd980194ccb86ebe58/Sim101' Name='Profit target' State=Cancelled Instrument='CL 09-11' Action=Sell Limit price=83.58 Stop price=0 Quantity=1 Type=Limit Tif=Gtc OverFill=False Oco='c6e90dae4c404858b8b527c224c4d254-827' Filled=0 Fill price=0 Token='06617919bf8740fd980194ccb86ebe58' Gtd='1/1/0001 12:00:00 AM' <<<
8/8/2011 12:21:14 PM Entered internal PlaceOrder() method at 8/8/2011 12:21:14 PM: BarsInProgress=0 Action=Sell OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Close' FromEntrySignal=''
>>> OrdeUpdate: Order='bad669435d544624b562dfcc442b7392/Sim101' Name='Close' State=PendingSubmit Instrument='CL 09-11' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='bad669435d544624b562dfcc442b7392' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='bad669435d544624b562dfcc442b7392/Sim101' Name='Close' State=Accepted Instrument='CL 09-11' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='bad669435d544624b562dfcc442b7392' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='bad669435d544624b562dfcc442b7392/Sim101' Name='Close' State=Working Instrument='CL 09-11' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='bad669435d544624b562dfcc442b7392' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeUpdate: Order='bad669435d544624b562dfcc442b7392/Sim101' Name='Close' State=Filled Instrument='CL 09-11' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Tif=Gtc OverFill=False Oco='' Filled=1 Fill price=83.44 Token='bad669435d544624b562dfcc442b7392' Gtd='1/1/0001 12:00:00 AM' <<<
>>> OrdeExecution: Execution='d19230a13f934a6a9b8cc07d981865dc' Instrument='CL 09-11' Account='Sim101' Name='Close' Exchange=Default Price=83.44 Quantity=1 Market position=Short Commission=0 Order='bad669435d544624b562dfcc442b7392' Time='8/8/2011 12:21:15 PM' <<<
>>> PositionUpdate <<<
### Non-ATM Position Closed
(ATM_MGR) -- CL Reset --
Non-ATM Position Closed
8/8/2011 12:21:15 PM Disable() called: strategy disabled
8/8/2011 12:21:15 PM CancelAllOrders: BarsInProgress=0
**NT** Disabling NinjaScript strategy 'A0_TradeManager/f35c6b9b33db4301979131b11304ad4e'
monpere is offline  
Reply With Quote
 

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
IB Server side OCO with parent order? tobbe SuperDOM and other Order Entry Windows 3 01-06-2012 02:02 AM
Unrealized profit display wrong in market analyzer, entry wrong in chart trader adamus Market Analyzer 3 06-17-2011 10:56 AM
error on picture's right side scale MoreYummy Miscellaneous Support 2 04-09-2010 09:54 AM
Error Sending Stop/Market order via Pats dct Connecting 11 10-28-2009 08:19 AM
Short Simulated Order Fills on Wrong Side Of Book Generic Miscellaneous Support 1 10-05-2008 04:27 PM


All times are GMT -6. The time now is 10:35 PM.