Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Unmanaged MIT BUY / SELL Orders Not Working As Expected

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

    Unmanaged MIT BUY / SELL Orders Not Working As Expected

    Submitting an unmanaged BUY order of type MIT, specifying the LIMIT price, and leaving the stop price at 0 since it is irrelevant, successfully creates an order that NEVER fires even when price > LIMIT. This occurs regardless of whether the price is greater or less than the LIMIT price when the order is placed.

    Can you please specify how to modify the code below to successfully submit a MIT LIMIT BUY and secondly a MIT LIMIT SELL order?

    BUY CODE
    SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.MIT, 1, entryPrice-TickSize,0, "", orderName);

    SELL CODE (OCO Profit LIMIT sell and stop loss orders)
    SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType. MIT,1,profitTargetPrice,0,strOCO,"ExitProfitMax");
    SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType. MIT,1,0,StopLossPrice,strOCO,"ExitStopLoss");

    #2
    Hello studio3d,
    Thanks for your post.

    Your code syntax looks fine to me so this is likely the logic used in your strategy. If you can answer these questions we can likely narrow down the issue.

    Are you back testing or testing on live data?

    You said 'the order was created but never fires'. How are you confirming this order was ever successfully created?

    What are your conditions for entry? How have you confirmed that these conditions became true?

    Are you using TraceOrders? If so, what does the print say?

    Are there any errors on the Logs tab of your Control Center?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      Are you back testing or testing on live data?
      I am using Market Replay data.
      Originally posted by NinjaTrader_JoshG View Post
      You said 'the order was created but never fires'. How are you confirming this order was ever successfully created?
      Yes. I have TraceOrders enabled. You can see the order is Submitted and Accepted. It is not ignored or cancelled.
      Entered internal SubmitOrderUnmanaged() method at 8/20/2018 6:41:05 AM: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=1 LimitPrice=2855.50 StopPrice=0 SignalName='EarlyTrendChangeEntry'

      Furthermore, I have code in OnOrderUpdate() as follows:
      Print(string.Format("DEBUGGGGGG - ORDER UPDATE: {0} - {1}",order.OrderState, Time[0]));

      It produces the following output:
      DEBUGGGGGG - ORDER PLACED: Submitted - 8/20/2018 6:41:04 AM
      DEBUGGGGGG - ORDER PLACED: Accepted - 8/20/2018 6:41:04 AM

      Originally posted by NinjaTrader_JoshG View Post
      What are your conditions for entry? How have you confirmed that these conditions became true?
      The conditions for entry would simply be that the price reaches the "limit" price of $2855.50. From what I've researched in the documentation and other threads for MIT orders, the price will have to reach one-tick above this amount to trigger the order ($2855.75 in this case) before triggering the actual market order. I can tell you that if I simply swap the LIMIT / STOP variables in the SubmitOrderUnmanaged call, it appears to work properly for the BUY in. However, this does not make logical sense for the STOP price to function as the LIMIT price for a BUY entry order. Additionally, I could find no such solution for the OCO profitExit / StopLoss strategy once the entry is executed.

      Originally posted by NinjaTrader_JoshG View Post
      Are you using TraceOrders? If so, what does the print say?
      See trace output as an answer to your question above.

      Originally posted by NinjaTrader_JoshG View Post
      Are there any errors on the Logs tab of your Control Center?
      There are no errors. The strategy continues to output debug log info properly and the order is finally cancelled at EOD when the market closes because I have it set to cancel any orders at market close.

      Comment


        #4
        As far as the order state goes, that is what I would expect since MIT orders are very different from any other order type. You can see the same behavior if you manually place an MIT order as well.

        In regards to whether you should be using the stop or the limit input, you should be using the STOP input since that is what MIT orders use.

        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Josh, part of our concept with our strategy using MIT orders is to effectively hide both our stop loss and profit exit orders. If the stop price is the only value for MIT orders, can you give an example of how to properly create the OCO situation shown in my initial post? For example, if the price is at $255, I want to have a OCO Sell to Close MIT order @ $260 (ExitProfitMax) and a StopLoss that triggers if we go down to $250 (ExitStopLoss). I haven't found a way to define this order when price is between them without having one of them IMMEDIATELY execute upon the order being placed.

          Comment


            #6
            I would expect something like the following snippet to be a correct way to accomplish your original post.

            Code:
            //BUY CODE
            SubmitOrderUnmanaged(0,OrderAction.Buy,OrderType.MIT,1,entryPrice,0,strOCO,orderName);
            
            //SELL CODE (OCO Profit LIMIT sell and stop loss orders)
            SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType.MIT,1,0,profitTargetPrice,strOCO,"ExitProfitMax");
            SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType.MIT,1,0,stopLossPrice,strOCO,"ExitStopLoss");
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Josh, the issue there is that setting a stoploss where stopLossPrice < price IMMEDIATELY triggers the order as soon as it is placed. The behavior I would expect for a Sell to Close would be to wait until the price drops TO or BELOW that stop price, but it is not what happens. So how can you have price at $255 and create a profit target MIT at $260 and a stoploss at $250 as described above?

              SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType. MIT,1,0,stopLossPrice,strOCO,"ExitStopLoss");

              Comment


                #8
                Josh, the issue here is still not resolved. Can you take a look at my last post?

                Comment


                  #9
                  So it seems that you will want to use MIT orders for your profit target and Stop Market orders for your stop loss.

                  //SELL CODE
                  SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType. MIT,1,0,profitTargetPrice,strOCO,"ExitProfitMax");
                  SubmitOrderUnmanaged(0,OrderAction.Sell,OrderType. StopMarket,1,0,stopLossPrice,strOCO,"ExitStopLoss" );
                  Let me know if you have any questions.
                  Josh G.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks NinjaTrader_JoshG!!!!!!!! I had the same problem and was RESOLVED!!!!!!!!!

                    Comment


                      #11
                      In an AddOn using Account.CreateOrder, there are four Order scenarios that I would like to achieve with MIT Orders.
                      They are the equivalent of the following:
                      • Buy Limit (OrderAction.Buy, OrderType.Limit, LimitPrice=value, StopPrice=0.0)
                      • Buy Stop (OrderAction.Buy, OrderType.StopMarket, LimitPrice=0.0, StopPrice=value)
                      • Sell Limit (OrderAction.SellShort, OrderType.Limit, LimitPrice=value, StopPrice=0.0)
                      • Sell Stop (OrderAction.SellShort, OrderType.StopMarket, LimitPrice=0.0, StopPrice=value)
                      What would be the equivalent MIT Order parameters to achieve the same with MIT Orders?

                      Thanks.
                      Multi-Dimensional Managed Trading
                      jeronymite
                      NinjaTrader Ecosystem Vendor - Mizpah Software

                      Comment


                        #12
                        Hello jeronymite,

                        MIT orders are a separate order type than Limit/Stop/Stop Limit orders. They are closely related to Limit orders and can be used in place of Limit orders, however the order does not reside at the exchange and they submit a Market order once triggered.

                        The equivalent for Stop Market orders if MIT is to Limit order would be a Simulated Stop Market order. This would involve using the customOrder parameter, however we do not offer any documentation or support for using this parameter to create simulated stops with AddOn Framework. You would have to use your own logic to check that the price has passed your defined level and submit a market order to achieve the same.

                        More information on MIT orders can be found here - https://ninjatrader.com/blog/hide-or...ed-orders-mit/

                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Thanks, Jim.

                          A few comments:
                          • First, an aside: can all blog posts by NinjaTrader that add useful information on the platform and its use always also be incorporated into the online Help documentation, please. When searching for information, it is the Help documentation that is the primary source. Blogs should not be the only location of such information, although highlighting such information via blogs is perfectly appropriate. Obviously, there are many already existing blog posts that may need to be reviewed for incorporation into the Help.
                          • Is there any documentation on how the customOrder is intended to be configured? It may not be comprehensive in the sense of examples of specific custom order usage, but one would hope for an explanation of how one might construct a customOrder. Otherwise, it is just a "black box" that might as well not be offered.
                          • I'm happy to create my own AddOn logic to control and manage orders locally. If that can be done by implementing a customOrder, I'm fine doing that, but, as mentioned above, some guidance on how to use customOrder is required. If it should be done separately from a customOrder, I simply need to know that and I can do it.
                          • From your advice, it seems that MIT Orders can directly replace Limit Orders (albeit with a change to the Buy/Sell side), but they cannot directly replace Stop Orders. Is that the case?
                          As always, your kind advice and support is most appreciated.

                          Thanks.
                          Multi-Dimensional Managed Trading
                          jeronymite
                          NinjaTrader Ecosystem Vendor - Mizpah Software

                          Comment


                            #14
                            Hello jeronymite,

                            • First, an aside: can all blog posts by NinjaTrader that add useful information on the platform and its use always also be incorporated into the online Help documentation, please. When searching for information, it is the Help documentation that is the primary source. Blogs should not be the only location of such information, although highlighting such information via blogs is perfectly appropriate. Obviously, there are many already existing blog posts that may need to be reviewed for incorporation into the Help.

                            We will be tracking interest behind adding an Order Types documentation page with the internal ticket ID SFT-4979. Until then we would suggest customers to refer to our educational videos on order types.

                            Our Order Entry 101 course goes over order types here (publicly available link) - https://youtu.be/YBs4cRXzE7c?t=1112

                            Although more NinjaScript focused, we do have a help guide documentation page on Order Types - https://ninjatrader.com/support/help...rder_types.htm

                            • Is there any documentation on how the customOrder is intended to be configured? It may not be comprehensive in the sense of examples of specific custom order usage, but one would hope for an explanation of how one might construct a customOrder. Otherwise, it is just a "black box" that might as well not be offered.
                            • I'm happy to create my own AddOn logic to control and manage orders locally. If that can be done by implementing a customOrder, I'm fine doing that, but, as mentioned above, some guidance on how to use customOrder is required. If it should be done separately from a customOrder, I simply need to know that and I can do it.

                            We do not offer any documentation or support for using the customOrder parameter. I know it used for Simulated Orders, but I don't have any insight for how it is used since it is not documented. If you want to keep orders local you would want to use your own logic. Some brokers like Rithmic and Interactive Brokers accept MIT orders natively, so for their case, the order will reside on their order routing servers (not on the exchange) and will convert to a market order once triggered.

                            • From your advice, it seems that MIT Orders can directly replace Limit Orders (albeit with a change to the Buy/Sell side), but they cannot directly replace Stop Orders. Is that the case?
                            Yes, MIT orders can be used in place of Limit orders, but not Stop Market orders.

                            We look forward to assisting.
                            JimNinjaTrader Customer Service

                            Comment


                              #15
                              Thanks, Jim. Your kind assistance is always much appreciated.
                              Multi-Dimensional Managed Trading
                              jeronymite
                              NinjaTrader Ecosystem Vendor - Mizpah Software

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ScottWalsh, 04-16-2024, 04:29 PM
                              6 responses
                              27 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by frankthearm, Today, 09:08 AM
                              10 responses
                              35 views
                              0 likes
                              Last Post frankthearm  
                              Started by GwFutures1988, Today, 02:48 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post GwFutures1988  
                              Started by mmenigma, Today, 02:22 PM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by NRITV, Today, 01:15 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post NRITV
                              by NRITV
                               
                              Working...
                              X