• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIT Execution Price in Historical Order Processing

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

    MIT Execution Price in Historical Order Processing

    The MIT execution price in the following example is not what I would expect. This is either a bug in the historical order processing or I'm confused why it does this.

    If you run the following strategy code you'll see the following completed trade on your chart.

    Click image for larger version  Name:	2019-07-16_22-32-36.png Views:	1 Size:	14.5 KB ID:	1064273

    The problem with this is that the exit happens at the MIT stop price, but should (I believe) happen at the open price.
    1. Submit EnterLong() on 3/12/2018
    2. Submit ExitLongMIT() in OnExecutionUpdate with a stop price below market.

    Now, I realize this is not really a good thing to do, but it is nonetheless behavior supported by NinjaTrader and something we may find ourselves running into from time to time.

    When OnExecutionUpdate runs for our entry, the market price is the open price.

    As I understand, MIT orders are simulated by NinjaTrader. When the price is touched, NinjaTrader submits a market order.

    Well, if that's the case, then the exit MIT order is triggered immediately and a market order is submitted.

    At that moment the market price would still be the open price.

    So, why doesn't the exit happen at the open instead of the MIT stop price?

    Thanks,
    Steve

    Code:
    public class MitExecutionPriceTest : Strategy
    {
    
        protected override void OnBarUpdate()
        {
            if (Time[0].Date == DateTime.Parse("2019-03-12").Date)
            {
                EnterLong("Tag1");
            }
    
        }
        protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
        {
            if (execution.Order.Name == "Tag1")
            {
                // We submit with a MIT stop price below the open. MIT should be
                // triggered immediately because it's below market. Then a market
                // order is submitted. The market price after the entry is the
                // open price. But the exit still executes at the MIT stop price.
                // I would expect it to execute at the open, the current market
                // price.
                ExitLongMIT(2790);
            }
        }
        protected override void OnStateChange()
        {
            // Load ES 06-19 Day bars on the chart going back to about 3/1/2019
    
            if (State == State.SetDefaults)
            {
                Name = "MIT Execution Price Test";
                IsExitOnSessionCloseStrategy = false;
                Slippage = 0;
                TraceOrders = true;
                BarsRequiredToTrade = 0;
            }
    
        }
    }
    Attached Files
    Last edited by Steve L; 07-16-2019, 08:57 PM.
    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    #2
    OK. I thought I understood how MIT orders work, but I'm pretty sure now that I don't.

    Are MIT orders triggered exactly like limit orders? Except with the only difference being that once the MIT is triggered it executes as a market order?

    Are MIT orders triggered when the price is actually TOUCHED or when the price threshold is exceeded? In the above example, we submit ExitLongMIT with a price of 2790. Is the MIT order triggered and executed the second it's submitted because the MIT price is exceeded? OR is the ExitLongMIT submitted and then only when the price reaches 2790 does it execute?
    Last edited by Steve L; 07-27-2019, 04:58 PM.
    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    Comment


      #3
      Hello Steve L,

      MIT orders are like stop market orders but are simulated and yes submit a market order once touched.

      I have a test script that tests updating these dynamically.
      https://ninjatrader.com/support/foru...79#post1055079

      With the order being submitted in OnExecutionUpdate() this would occur before the submission bar closes (so would not be at the open of the next bar) and would be intra-bar but likely without intra-bar data.

      I would recommend intra-bar granularity for this kind of intra-bar actions.
      https://ninjatrader.com/support/foru...377#post773377
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by PG7940, Today, 04:26 AM
      0 responses
      2 views
      0 likes
      Last Post PG7940
      by PG7940
       
      Started by marcus2300, Today, 02:25 AM
      0 responses
      2 views
      0 likes
      Last Post marcus2300  
      Started by drpapp, 01-24-2019, 06:57 AM
      5 responses
      69 views
      0 likes
      Last Post pjsmith
      by pjsmith
       
      Started by plydcv, Today, 12:40 AM
      0 responses
      3 views
      0 likes
      Last Post plydcv
      by plydcv
       
      Started by Sh00tHerMcGavin, Yesterday, 07:39 PM
      0 responses
      4 views
      0 likes
      Last Post Sh00tHerMcGavin  
      Working...
      X