Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIT is touch but Positions don't update and Order is still working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MIT is touch but Positions don't update and Order is still working

    Hi,

    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
    I see that on the 5/7/2018 9:35-9:40 bar, the Low of 69.9 breached the limitPrice of 69.99

    (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
    where the MIT Order gets filled even though the LimitPrice of 70.81 is not touched


    (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



    Last edited by uday12; 06-04-2019, 07:46 AM.

    #2
    Hello uday12,

    While the IsFillLimitOnTouch would not affect MIT orders (Market If Touched) I would expect a market order to have filled if the order was touched.

    Is this happening for all MIT orders or just some?

    Have you created a simple test script do demonstrate this behavior? (That removes all custom logic and places an order without any complex entry conditions)
    If so, may I test an export of your test script? (Tools > Export > NinjaScript Addon)

    If not, let me know and I will create a simple test script to test.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      I found the issue. For MIT orders with SubmitOrderUnmanaged, I needed to use StopPrice = myPriceLevel with LimitPrice=0, but I was instead using LimitPrice = myPriceLevel with StopPrice=0.

      so, this:

      order = SubmitOrderUnmanaged(BarsInProgress, OrderAction.Sell, OrderType.MIT, 740, 70.81, 0);

      needed to be changed to :

      order = SubmitOrderUnmanaged(BarsInProgress, OrderAction.Sell, OrderType.MIT, 740, 0, 70.81);

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X