This morning, after successfully executing a trade for 100 shares (live trading), NT attempted to modify my profit target for 10.1k shares. This was rejected by my broker due to the size and the strategy became disabled.
I ran the following sequence:
if(triggerLong)
{
EnterLong(100); this.SetProfitTarget(CalculationMode.Price,Close[0]+ATR(14)[0]*3);
}
4/18/16 8:31 Order
At this point I was long 100 shares as I should be.
Order='739564834/Uxxxxx' Name='Buy' New state='Filled' Instrument='AAPL' Action='Buy' Limit price=0 Stop price=0 Quantity=100 Type='Market' Time in force=GTC Oco='' Filled=100 Fill price=108.7992 Error='No error' Native error=''
Next it shows the order for setting the profit target, as it should be.
4/18/16 8:32 Order Order='739564836/Uxxxx Name='Profit target' New state='Working' Instrument='AAPL' Action='Sell' Limit price=109.19 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='AAPL/0000d73b.5714db4a.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
4/18/16 8:32 Order Order='739564836/Uxxxx' Name='Profit target' New state='Accepted' Instrument='AAPL' Action='Sell' Limit price=109.19 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='AAPL/0000d73b.5714db4a.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
4/18/16 8:32 Order Order='0e8bb48280a942f39ac747abca1eff2c/Uxxxx' Name='Profit target' New state='Submitted' Instrument='AAPL' Action='Sell' Limit price=109.19 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='AAPL/0000d73b.5714db4a.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
At 9:02, the strategy hit this logic:
If(shouldExit)
{
ExitLong(100);
}
This worked as expected, however as it was executing to exit, NT started modifying the profit target, and at one point attempted to submit an order with 10.1k as quantity:
4/18/16 9:02 Order Order='c11c51ddccbf4fc8856d20a8cb17e347/Uxxxxx' Name='Sell' New state='Submitted' Instrument='AAPL' Action='Sell' Limit price=0 Stop price=0 Quantity=100 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
4/18/16 9:02 Execution Execution='AAPL/00014229.57149676.01.01' Instrument='AAPL' Account='Uxxx' Exchange=Default Price=108.29 Quantity=100 Market position=Short Operation=Operation_Add Order='739564838' Time='4/18/2016 9:03 AM'
4/18/16 9:02 Order Order='739564838/Uxxx' Name='Sell' New state='Filled' Instrument='AAPL' Action='Sell' Limit price=0 Stop price=0 Quantity=100 Type='Market' Time in force=GTC Oco='' Filled=100 Fill price=108.29 Error='No error' Native error=''
4/18/16 9:02 Order Order='739564836/Uxx' Name='Profit target' New state='Change submitted' Instrument='AAPL' Action='Sell' Limit price=109.19 Stop price=0 Quantity=10.1K Type='Limit' Time in force=GTC Oco='AAPL/0000d73b.5714db4a.01.01' Filled=0 Fill price=0 Error='No error' Native error=''
That last execution above is when it attempted to do a quantity of 10.1K. At this point I end up with rejected messages from broker, and strategy goes to disabled.
Any idea what is wrong in my logic that caused this? Should I have sent a cancel order myself before exiting the position?
The fact that my strategy became disabled due to an order too large is a bit scary since this is running on real money....
Comment