Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MIT Orders in Unmanaged Order Entries

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

    MIT Orders in Unmanaged Order Entries

    Hi everyone,

    I've got a question regarding unmanaged Order submissions.

    I want to use brackets for my unmanaged orders, with a StopLoss and a TakeProfit.

    Let's say I am entering with 5 contracts long like so:

    Code:
    SubmitOrderUnmanaged(1, OrderAction.Buy, OrderType.Market, 5, 0, 0, string.Empty, entryName);
    Afterwards, in OnExecutionUpdate, I am placing my TP and SL after first checking if the Order has fully filled (which it always does, because it's a market order).

    Like so:

    Code:
    currentPtPrice = execution.Order.AverageFillPrice + X;
    profitTargetLong = placeHolderOrder;
    SubmitOrderUnmanaged(1, OrderAction.Sell, OrderType.Limit, 5, currentPtPrice, 0, ocoString, "profit target");
    
    currentSlPrice = execution.Order.AverageFillPrice - X;
    stopLossLong = placeHolderOrder;
    SubmitOrderUnmanaged(1, OrderAction.Sell, OrderType.StopMarket, 5, 0, currentSlPrice, ocoString, "stop loss");
    This approach works wonderful, however, I don't want to concern myself with open position contract size management.
    Meaning, if somehow my TP Limit only get's partially filled and the chart reverses, hits my SL and now I'm short a couple contracts...

    That's why I want to replace my TP with a Market if Touched Order.

    However, if I simply change it to MIT, it places the order at zero, completely disregarding my previously calculated currentPtPrice.
    I have tried using MIT, and also changing the OrderAction to StopMarket to no avail.

    Any pointers would be very welcomed.
    Also, how dows it work with Short setups?
    I have set the OrderAction to Buy, but I'm not sure if I should be using BuyToCover and if so, what OrderType I should be using for my TP?

    And if there were another way for me to pass my initial entry Contract Size to the TP and SL orders, that would be wonderful as well!
    (I was thinking execution.Order.Filled, but that throws me an error...)

    Cheers

    #2
    Hello totalnewbie,

    Have you tried switching the stop and limit prices in the parameters in your actual script to see if that works?

    Regarding the order types. You can use the chart trader to submit orders on a specific side of the market to learn which order types are needed. The easiest way is to place the order and let it fill, look in the control center orders tab to see what was generated and then mirror that in your code.

    To pass a quantity to this method you need to make a variable. If you have the order in another condition you can use a private variable to store a quantity.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse,

      I'm not exactly sure what you mean by "switching the stop and limit prices in the parameters in your actual script".
      Do you mean renaming the parameters?

      I know what Order Types there are. I want to make my take profit (in a long trade: above the current price and my entry), to be a Market if Touched order.
      So that it always fills to its full extend (e.g. the contract size). Do you understand what I mean?

      The only problem is, if I set my TakeProfit SubmitOrderUnmanaged to OrderType.MIT, it somehow doesn't place it at the currentPtPrice.
      That's why I asked about the combination of OrderAction and OrderType to use for it to place the TP as a MIT above the current price. (and vice versa in a short trade).

      Best regards

      Comment


        #4
        Hello totalnewbie,

        If you are getting a 0 price that may be that you put the prices in the wrong parameter based on the direction.

        SubmitOrderUnmanaged(int selectedBarsInProgress, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice)

        To make a take profit for a long order you need to use the appropriate order type and a price above market.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Alright, now I get it.

          I did put them in the correct order though, didn't I? Please take a look at the code snippet from my initial post.
          Or do I have to put the take profit if it's a MIT also in the double stopPrice place?

          //EDIT: Figured it out, when using MIT, you'll need to set the price Parameter as the double stopPrice.
          Last edited by totalnewbie; 02-14-2025, 11:46 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ybforex, 03-11-2025, 05:30 PM
          11 responses
          98 views
          0 likes
          Last Post ybforex
          by ybforex
           
          Started by forgebench, Today, 02:22 PM
          2 responses
          9 views
          0 likes
          Last Post forgebench  
          Started by MamaKB, 02-14-2025, 03:38 PM
          10 responses
          84 views
          0 likes
          Last Post Fertryd2  
          Started by Irukandji, Today, 03:46 PM
          0 responses
          7 views
          0 likes
          Last Post Irukandji  
          Started by HappyTrader76, Yesterday, 04:14 PM
          8 responses
          48 views
          0 likes
          Last Post HappyTrader76  
          Working...
          X