Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Noob Question - MIT Orders

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

    Noob Question - MIT Orders

    Let me start off by saying, sorry for the noob question. I'm not a programmer at all but I'm trying to learn. I currently use a strategy with EnterLongLimit and EnterShortLimit orders. With the strategy an order is placed when certain conditions are meet, but the order will be canceled if the following candle after the order is placed doesn't trigger a trade. I changed the order type to a MIT order (EnterLongMIT and EnterShortMIT). When the condition is meet to place the MIT order is placed and it's yellow. I know yellow means the order is in a "Trigger Pending" status and is held locally on my PC. My question or problem is, if the MIT order isn't triggered by the following candle close the order doesn't cancel and just stays in a "Trigger Pending" status until the price reaches it. Does anyone know how to correct this? This doesn't happen when I use the EnterLongLimit and EnterShortLimit orders. Thank you in advance.

    #2
    Hello lacerda4269,

    Thank you for your post.

    The default behavior for stop and limit orders is for them to be canceled once the trigger conditions are no longer true. Since the MIT is not being canceled, this suggests that the condition to submit the MIT is still true. What condition are you using to trigger the MIT? You could use prints to verify the values being compared and see if they are still true, hence still keeping the MIT order "alive" for more than one bar. For more details on using prints to debug your scripts:


    For example, the following test strategy submits an MIT order and if it is not filled by the end of the bar, it is automatically canceled because the condition to submit it is no longer true:

    Code:
            private bool doOnce;
            protected override void OnStateChange()
            {
                else if (State == State.DataLoaded)
                {
                    doOnce = false;
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (State == State.Historical)
                    return;
                if (doOnce == false)
                {
                    EnterLongMIT(Close[0] - 20 * TickSize);
                    doOnce = true;
                }
            }​
    Please let me know if I may be of further assistance.

    Comment


      #3
      Good morning Emily,

      Thank you very much for the response! What you mention does make sense. I will have to play around with the code. In the example you gave, you wrote, "the following test strategy submits an MIT order and if it is not filled by the end of the bar, it is automatically canceled because the condition to submit it is no longer true." When you wrote, is not filled by the end of the bar. Did you mean the bar that started as soon as the MIT order was placed? I hope so, because that would make my life so much easier trying to incorporate what you written. Once again sorry for the noob question/remark.
      ​​​​​​

      Comment


        #4
        Originally posted by lacerda4269 View Post
        Good morning Emily,

        Thank you very much for the response! What you mention does make sense. I will have to play around with the code. In the example you gave, you wrote, "the following test strategy submits an MIT order and if it is not filled by the end of the bar, it is automatically canceled because the condition to submit it is no longer true." When you wrote, is not filled by the end of the bar. Did you mean the bar that started as soon as the MIT order was placed? I hope so, because that would make my life so much easier trying to incorporate what you written. Once again sorry for the noob question/remark.
        ​​​​​​
        No worries about the "noob" questions! We are glad to assist our users of all skill levels and these are still good questions to gain a deeper understanding of how NInjaScript strategies work. The bar I am referring to is the bar on which the MIT order was placed, yes. You could test this out calculating OnPriceChange or OnEachTick and that could result in the order being placed intra-bar and as soon as that bar completes, if the order was not filled it is canceled. If you test this calculating OnBarClose, then the order would be submitted as soon as a new bar begins to form and if it is not filled by the end of that bar it will be canceled as soon as the bar closes and the next bar begins.

        Rather than allowing orders to "expire" and be canceled at the end of the bar if they are not filled and the conditions are no longer met, the following reference samples deal with the concept of keeping orders alive with IsLiveUntilCanceled as well as using CancelOrder() to explicitly cancel orders:



        Live until canceled orders are also addressed on the Advanced Order Handling page here:


        Please feel free to reach out with any additional questions or concerns.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        51 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        127 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X