I'm having some problems with orders that are meant to be OCO. Basically what seems to be happening is that a stoploss is trailed, and virtually at the same time the target fills, which correctly cancels the stoploss order, but the trail command is still on its way and it puts on a new stoploss order for the position, causing an overfill on this trade.
See screenshot of the trade.
Here is output from the strategy, showing the events. I presume it is the new multi-threaded event driven nature of NT8 that is capable of this, so what I would like to get is a procedure that is not prone to this kind of behaviour.
3/16/2017 7:43:28 AM trailing LS1 to 1228.8
3/16/2017 7:43:30 AM Strategy 'dlSwingsStrategy/101134163': Entered internal SubmitOrderManaged() method at 3/16/2017 7:43:30 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=2 LimitPrice=0 StopPrice=1228.8 SignalName='LS1' FromEntrySignal='LE1'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=ChangePending instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1227.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=ChangeSubmitted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
3/16/2017 7:43:30 AM Strategy 'dlSwingsStrategy/101134163': Amended matching order at 3/16/2017 7:43:30 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=2 LimitPrice=0 StopPrice=1228.8 SignalName='LS1' FromEntrySignal='LE1'
3/16/2017 7:43:28 AM trailing LS2 to 1228.8
3/16/2017 7:43:30 AM Strategy 'dlSwingsStrategy/101134163': Entered internal SubmitOrderManaged() method at 3/16/2017 7:43:30 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=1228.8 SignalName='LS2' FromEntrySignal='LE2'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=ChangePending instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1227.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=ChangeSubmitted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
3/16/2017 7:43:30 AM Strategy 'dlSwingsStrategy/101134163': Amended matching order at 3/16/2017 7:43:30 AM: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=1 LimitPrice=0 StopPrice=1228.8 SignalName='LS2' FromEntrySignal='LE2'
OnOrderUpdate(): orderId='a15537f8ae384841b48ff696da9ce467' account='Sim101' name='LT1' orderState=PartFilled instrument='GC 04-17' orderAction=Sell orderType='Limit' limitPrice=1229.1 stopPrice=0 quantity=2 tif=Gtc oco='' filled=1 averageFillPrice=1229.1 onBehalfOf='' id=562 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='a15537f8ae384841b48ff696da9ce467' account='Sim101' name='LT1' orderState=Filled instrument='GC 04-17' orderAction=Sell orderType='Limit' limitPrice=1229.1 stopPrice=0 quantity=2 tif=Gtc oco='' filled=2 averageFillPrice=1229.1 onBehalfOf='' id=562 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
3/16/2017 7:43:30 AM Strategy '101134163/dlSwingsStrategy: Cancelled pending exit order, since associated position is closed, orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=ChangeSubmitted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=CancelPending instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=CancelSubmitted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=Accepted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=Accepted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:43:30' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=Working instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=561 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=Working instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=Filled instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=2 averageFillPrice=1228.8 onBehalfOf='' id=561 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
3/16/2017 7:45:55 AM Strategy '101134163/dlSwingsStrategy: Cancelled pending exit order, since associated position is closed, orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=Working instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=CancelPending instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=CancelSubmitted instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='5b38bf9579a741af85f91388b10761ed' account='Sim101' name='LS1' orderState=Cancelled instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=2 tif=Gtc oco='' filled=2 averageFillPrice=1228.8 onBehalfOf='' id=561 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
OnOrderUpdate(): orderId='fa8ee9bcb60743febd0cdc48f76aa12d' account='Sim101' name='LS2' orderState=Cancelled instrument='GC 04-17' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=1228.8 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=563 time='2017-03-16 07:45:55' gtd='2099-12-01' statementDate='2017-03-16'
Cheers,
saltminer
Comment