a strategy that loads additional bar series is experiencing knowing about fills before they can happen. Attached is a picture which shows a stop entry order Long at 101.89, placed at the time of the close of the 2:00AM bar, fills during the bar that closes at 2:10AM.
Unfortunately Ninja advises of this fill in advance, at 2:05. This screws up some other logic in the strategy to do with entry order cancellation on a bar against the trade direction (note the red bar of 2:05AM).
If, at the time of the close of the bar at 2:05 the strategy knew it had had a red bar, it would have cancelled the long entry order and never been filled. Unfortunately at 2:05 there is a fill erroneously advised.
See this excerpt from OutputWindow text. Note the fill at 2:05AM. I am catching Executions in OnExecution() and placing stop and target orders there.
7/01/2016 2:00:00 AM Entered internal SubmitOrder() method at 7/01/2016 2:00:00 AM: Action=Buy OrderType=Stop Quantity=49 LimitPrice=0 StopPrice=101.89 OcoId='a7947ad2457c40e8a7a1165c8c6be650' Name='LE_AAPL_msStockGroupBreakoutsV2'
msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00007/Backtest' Name='SE_AAPL_msStockGroupBreakoutsV2' State=PendingCancel Instrument='AAPL' Action=SellShort Limit price=0 Stop price=100.2 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='294e4b123e074631b7c889c744bb176b' Filled=0 Fill price=0 Token='0fcef0bbb95e4448bae5f0770d74c377' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00007/Backtest' Name='SE_AAPL_msStockGroupBreakoutsV2' State=Cancelled Instrument='AAPL' Action=SellShort Limit price=0 Stop price=100.2 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='294e4b123e074631b7c889c744bb176b' Filled=0 Fill price=0 Token='0fcef0bbb95e4448bae5f0770d74c377' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=PendingSubmit Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Accepted Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:00:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Working Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=0 Fill price=0 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00008/Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' State=Filled Instrument='AAPL' Action=Buy Limit price=0 Stop price=101.89 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='a7947ad2457c40e8a7a1165c8c6be650' Filled=49 Fill price=101.89 Token='7378ba57a5414c9db4303fa7e9472611' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnExecution(): Execution='NT-00004' Instrument='AAPL' Account='Backtest' Name='LE_AAPL_msStockGroupBreakoutsV2' Exchange=Default Price=101.89 Quantity=49 Market position=Long Commission=0 Order='NT-00008' Time='7/01/2016 2:10:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM Placing initial stop for Long trade LE_AAPL_msStockGroupBreakoutsV2 at 100.38
7/01/2016 2:05:00 AM Entered internal SubmitOrder() method at 7/01/2016 2:05:00 AM: Action=Sell OrderType=Stop Quantity=49 LimitPrice=0 StopPrice=100.38 OcoId='' Name='LS_AAPL_msStockGroupBreakoutsV2'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=PendingSubmit Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=Accepted Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
msStockGroupBreakoutsV2 7/01/2016 2:05:00 AM OnOrderUpdate(): Order='NT-00009/Backtest' Name='LS_AAPL_msStockGroupBreakoutsV2' State=Working Instrument='AAPL' Action=Sell Limit price=0 Stop price=100.38 Quantity=49 Strategy='msStockGroupBreakoutsV2' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='036ecacad50d41f385ff3e184f7afde8' Gtd='1/12/2099 12:00:00 AM'
This is NT7 v31.
Please advise,
saltminer
Comment