I wanted to understand MIT better. In my strategy, which is using IsUnmanaged = true (and I also have IsFillLimitOnTouch = true).
I get situations where MIT order should get executed (in Sim101), but does not actually get executed, and vice versa, where the MIT order should not get executed but ends up getting executed
For instance: I am running this backtest on CL 07-19, on 1-hourly bar and observing the state of the OrderState on the 5 minute bar.
CASE 1 (MIT Buy didn't get filled even though Low was below Limit Price)
(1) Initial 1-hour Bar: Date/Time: 2018-05-07 09:00, OHLC : 70.29, 70.56, 70.28, 70.49, Position = 0.
Buy MIT order issued for a limit price of 69.99 and quantity of 370, and the order was valid for the next hourly bar.
<previously issued, another bars before>
order = SubmitOrderUnmanaged(BarsInProgress, OrderAction.Buy, OrderType.MIT, 386, 69.6, 0);
<but modified on this bar to>
ChangeOrder(order, 370, 69.99, 0);
Here's the message I get:
5/7/2018 9:00:00 AM Strategy 'AdvancedEn3/171078843': Changed custom managed order: orderId='NT-00001-108' account='Sim101' name='Buy' orderState=Working instrument='CL 07-19' orderAction=Buy orderType='MIT' limitPrice=69.9 stopPrice=0 quantity=370 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2018-05-04 12:00:00' gtd='2099-12-01' statementDate='2019-06-04' limitPriceChanged=69.99 quantityChanged=370 stopPriceChanged=0
(2) I used an additional 5 min data to print what is happening in the next hourly bar.
| Time | Order State | Open | High | Low | Close |
| 5/7/2018 9:00 | Long Limit Order State: Working | 70.52 | 70.56 | 70.48 | 70.49 |
| 5/7/2018 9:05 | Long Limit Order State: Working | 70.49 | 70.49 | 70.36 | 70.43 |
| 5/7/2018 9:10 | Long Limit Order State: Working | 70.43 | 70.44 | 70.39 | 70.42 |
| 5/7/2018 9:15 | Long Limit Order State: Working | 70.41 | 70.42 | 70.33 | 70.4 |
| 5/7/2018 9:20 | Long Limit Order State: Working | 70.39 | 70.41 | 70.32 | 70.32 |
| 5/7/2018 9:25 | Long Limit Order State: Working | 70.32 | 70.33 | 70.11 | 70.2 |
| 5/7/2018 9:30 | Long Limit Order State: Working | 70.2 | 70.22 | 70.11 | 70.11 |
| 5/7/2018 9:35 | Long Limit Order State: Working | 70.11 | 70.11 | 69.9 | 69.93 |
| 5/7/2018 9:40 | Long Limit Order State: Working | 69.92 | 70.16 | 69.88 | 70.06 |
| 5/7/2018 9:45 | Long Limit Order State: Working | 70.07 | 70.15 | 70.04 | 70.09 |
| 5/7/2018 9:50 | Long Limit Order State: Working | 70.09 | 70.13 | 69.98 | 70.03 |
| 5/7/2018 9:55 | Long Limit Order State: Working | 70.03 | 70.15 | 70.02 | 70.11 |
(3) on the next hourly bar: Date/Time: 2018-05-07 10:00, OHLC : 70.49, 70.49, 69.88, 70.12 (low on the hourly bar is less than 69.99), but Position = 0.
Why did the MIT order not get executed, when clearly the Low price reached within the bar is less than the Limit Price?
CASE 2 (MIT Sell got filled even though High was below Limit Price)
(1) Initial 1-horu Bar: Date/Time: 2018-05-07 09:00, OHLC : 70.49, 70.49 , 69.88 , 70.12, Position = 0.
Sell MIT order issued for a limit price of 70.81 and quantity of 740, and the order was valid for the next hourly bar.
Cancel(order);
order = null;
order = SubmitOrderUnmanaged(BarsInProgress, OrderAction.Sell, OrderType.MIT, 740, 70.81, 0);
Here's the message I get:
<previous Buy MIT cancelled>
5/7/2018 10:00:00 AM Strategy 'AdvancedEn3/171078843': Cancelled custom managed order: orderId='NT-00001-108' account='Sim101' name='Buy' orderState=Working instrument='CL 07-19' orderAction=Buy orderType='MIT' limitPrice=69.99 stopPrice=0 quantity=370 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2018-05-04 12:00:00' gtd='2099-12-01' statementDate='2019-06-04'
<new Sell MIT issued>
5/7/2018 10:00:00 AM Strategy 'AdvancedEn3/171078843': Entered internal SubmitOrderUnmanaged() method at 5/7/2018 10:00:00 AM: BarsInProgress=0 Action=Sell OrderType=MIT Quantity=740 LimitPrice=70.81 StopPrice=0 SignalName=''
(2) On the 5-min bar I see
| Time | Order State | Open | High | Low | Close |
| 5/7/2018 10:00 | Short Limit Order State: Working | 70.11 | 70.13 | 69.99 | 70.12 |
| 5/7/2018 10:05 | Short Limit Order State: Filled | 70.11 | 70.15 | 70.05 | 70.12 |
| 5/7/2018 10:10 | Short Limit Order State: Filled | 70.12 | 70.35 | 70.11 | 70.31 |
| 5/7/2018 10:15 | Short Limit Order State: Filled | 70.31 | 70.35 | 70.24 | 70.34 |
| 5/7/2018 10:20 | Short Limit Order State: Filled | 70.34 | 70.39 | 70.19 | 70.21 |
| 5/7/2018 10:25 | Short Limit Order State: Filled | 70.21 | 70.24 | 70.15 | 70.24 |
| 5/7/2018 10:30 | Short Limit Order State: Filled | 70.24 | 70.29 | 70.17 | 70.17 |
| 5/7/2018 10:35 | Short Limit Order State: Filled | 70.18 | 70.23 | 70.13 | 70.2 |
| 5/7/2018 10:40 | Short Limit Order State: Filled | 70.21 | 70.23 | 70.13 | 70.17 |
| 5/7/2018 10:45 | Short Limit Order State: Filled | 70.17 | 70.2 | 70.07 | 70.13 |
| 5/7/2018 10:50 | Short Limit Order State: Filled | 70.13 | 70.32 | 70.11 | 70.28 |
| 5/7/2018 10:55 | Short Limit Order State: Filled | 70.28 | 70.35 | 70.26 | 70.32 |
(3) On the next hourly bar, Date/Time : 2018-05-07 1100, OHLC: 70.11, 70.53, 70.05, 70.31, I see the Position = -740 (short 740), but even the hourly bar shows that the High was less than the LimitPrice

Comment