I am running an automated strategy, trading Nasdaq stocks intraday. On entry, the strategy submits both a stop loss and a profit target limit order.
The problem: The strategy often terminates itself. On execution of the stop-loss order, Ninja runs into some problem with managing the orders (Error message: "Can't modify a filled order" or "Order not in cancellable status", see NT log below). What's worse, on termination, Ninja submits a "Close" order for what it thinks is still an active long position (which by then is closed!), thus opening an irregular short position.
How can I prevent this from happening?
Many thanks
Martin
Log output:
------------------
6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=Working Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:18 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PartFilled Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''
6/12/2008 8:43:18 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=350 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=200 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508011/U123456' Name='Stop loss' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=0 Stop price=24.26 Quantity=400 Type=Stop Filled=50 Fill price=24.24 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=100 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Working Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=0 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=PendingChange Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Accepted Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=NoError Native error=''
6/12/2008 8:43:19 PM|1|32|Order='2146508012/U123456' Name='Profit target' New State=Rejected Instrument='YHOO' Action=Sell Limit price=25.76 Stop price=0 Quantity=350 Type=Limit Filled=0 Fill price=0 Error=OrderRejected Native error='Can't modify a filled order" (104)'
6/12/2008 8:43:19 PM|0|32|Can't modify a filled order" (104) Affected Order: Sell 350 Limit @ 25.76
6/12/2008 8:43:19 PM|0|128|Strategy 'xxxxx' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
6/12/2008 8:43:19
PM|1|32|Order='797f914ceb764ff8b0ac0ae378698df7/U123456' Name='Close' New State=PendingSubmit Instrument='YHOO' Action=Sell Limit price=0 Stop price=0 Quantity=350 Type=Market Filled=0 Fill price=0 Error=NoError Native error='' [THIS CAUSES AN IRREGULAR SHORT RIGHT HERE]
Comment