Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Orders, few questions...

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

    Unmanaged Orders, few questions...

    I am writing some order logic that includes a standard stoploss and potential take profit order to be submit upon an order being either partially filled or fully filled.

    1.With this in mind is there any documentation that better explains the following based on the SubmitOrderUnmanaged documentation:

    OrderAction - What are the differences between BuyToCover, SellShort etc
    Code:
    Determines if the order is a buy or sell order
     
    Possible values:
     
    OrderAction.Buy
    OrderAction.BuyToCover
    OrderAction.Sell
    OrderAction.SellShort
    OrderType
    Code:
    Determines the type of order submitted
     
    Possible values:
     
    OrderType.Limit
    OrderType.Market
    OrderType.MIT
    OrderType.StopMarket
    OrderType.StopLimit
    How does the StopMarket, StopLimit order work? Assume the following:
    1. I place an order to BUY 10 contracts
    2. I get a part fill of 7
    3. Moments later I get a full fill of 10 contracts


    What is the correct way to handle a stoploss with unmanaged orders:

    Option 1
    1. On part fill of 7 I submit unmanaged order to SELL 7 at stoploss price
    2. Upon full fill I change the original stoploss order to now SELL 10 contracts


    Option 2
    1. On part fill of 7 I submit StopMarket or StopLimit order at stoploss price
    2. Will the prior order placed know to exit the full position no matter what the current fill level is, full or part?


    Thanks, probably more questions to come...

    #2
    Hello fxRichard,

    Thank you for your note.

    Is there a reason you’ve chosen the unmanaged vs managed approach?

    Under the Managed Approach, in your example, if you got filled on 7 of 10 a stop loss would be submitted for 7 contracts until the remaining 3 were filled at which point another 3 contract stop loss would be placed.

    I would encourage you to read in detail the difference between managed vs unmanaged.

    Unmanaged: http://ninjatrader.com/support/helpG...d_approach.htm
    Managed: http://ninjatrader.com/support/helpG...d_approach.htm

    Unmanaged Example Download:


    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response Alan. I have read through all of the differences between managed, advanced managed and unmanaged order handling. I am doing a combination of advanced managed and unmanaged between a few different strategies (obviously not together in one strategy as you have to choose ahead of time).

      On a side note I have a question about the managed order handling. What are the order of events for an entry order when a take profit or stop loss have been hit and filled? Does the original entry order get and events as it wouldn't technically be "canceled" as I imagine a canceled state only applies to pending orders.

      Would I simply need to look for the stoploss or takeprofit orders to be filled and then null out my original entry order or is there some other event for the entry order in this case? Thanks.

      Comment


        #4
        Originally posted by fxRichard View Post
        On a side note I have a question about the managed order handling. What are the order of events for an entry order when a take profit or stop loss have been hit and filled? Does the original entry order get and events as it wouldn't technically be "canceled" as I imagine a canceled state only applies to pending orders.
        When the entry order is filled, you'd "know" that by checking for it in OnExecution. As part of the OnExecution processing for that order, you'd want to submit your stop loss order and profit target order from there. Before returning, you'd set your entry order variable to null.

        Effectively, your entry order (once filled) and its stop loss and profit target orders are never active at the same time.

        If you think about it, this makes sense -- but also, realize a subtle difference: when your entry order is partial filled, yes, all 3 orders could be active at the same time.

        Obviously, "partial filled" and "filled" are similar but still very different, and must be handled differently, too.

        Originally posted by fxRichard View Post
        Would I simply need to look for the stoploss or takeprofit orders to be filled and then null out my original entry order or is there some other event for the entry order in this case?
        No, after the entry order is filled, set your entry order variable to null right there.

        There is no need to wait for the stop loss or take profit orders to be filled.

        Why? Once the entry order enters the "filled" state, there is no other next state for it to transition to. This is because "filled" is a terminating state (similar to how "cancelled" is a terminating state), meaning the system lifecycle of that order is over.

        So, since the order's lifecycle is complete when an order is filled or cancelled, you can safely nullify the order variable when it transitions to that state.
        Last edited by bltdavid; 10-25-2016, 06:10 PM.

        Comment


          #5
          Originally posted by fxRichard View Post
          OrderAction - What are the differences between BuyToCover, SellShort etc
          Code:
          Determines if the order is a buy or sell order
           
          Possible values:
           
          OrderAction.Buy
          OrderAction.BuyToCover
          OrderAction.Sell
          OrderAction.SellShort
          Using the open/close metaphor to open and close a position, think of it this way:

          LONG position:
          BuyToOpen - OrderAction.Buy
          SellToClose - OrderAction.Sell

          SHORT position:
          SellToOpen - OrderAction.SellShort
          BuyToClose - OrderAction.BuyToCover

          In fact, I prefer the Open/Close metaphor and use the following in my code,

          Code:
                  // long positions
                  protected const OrderAction     BuyToOpen       = OrderAction.Buy;
                  protected const OrderAction     SellToClose       = OrderAction.Sell;
          
                  // short positions
                  protected const OrderAction     SellToOpen       = OrderAction.SellShort;
                  protected const OrderAction     BuyToClose      = OrderAction.BuyToCover;

          Comment


            #6
            Hello fxRichard,

            Thank you for your response.

            There is no additional documentation on the Unmanaged Order Approach.

            For the OrderActions:
            Buy is an entry to enter a long position.
            BuyToCover is an exit order for a short position.
            Sell is an exit order for a long position.
            SellShort is an entry to enter a short position.

            If you are unsure on the OrderTypes I would recommend researching these online. You can find a lot of useful information on the web: http://www.investopedia.com/universi...o-order-types/

            When you enter into a partial quantity of the desired position you either need to change the quantity of the protective orders upon the full fill of the entry quantity or submit a new order for the remaining quantity.

            For the order of events on the entry order when the Stop Loss or Profit Target fill in the Managed Approach;

            NinjaTrader will check the Position.MarketPosition of the strategy.

            NinjaTrader will verify the EntriesPerDirection and EntryHandling.

            If the position is flat and the EntriesPerDirection is not exceeded and the EntryHandling is met, then a new order can be submitted.

            If you wished to replicate making the entry order ready in Unmanaged Approach you would ensure your conditions are met, whether they are the entry conditions and/or position and number of active entries.

            Unmanaged gives you the freedom to determine the behavior. A better question would be, what behavior do you want to occur and why.

            Please let me know if you have any questions.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_AlanP View Post
              Unmanaged gives you the freedom to determine the behavior. A better question would be, what behavior do you want to occur and why.
              In my experience, ScaleIn/ScaleOut are best done using unmanaged.

              Also, handling rejected orders and overfills is much simpler using unmanaged.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NM_eFe, Today, 05:15 PM
              0 responses
              2 views
              0 likes
              Last Post NM_eFe
              by NM_eFe
               
              Started by vitaly_p, Today, 05:09 PM
              0 responses
              1 view
              0 likes
              Last Post vitaly_p  
              Started by cmtjoancolmenero, Today, 05:05 PM
              0 responses
              1 view
              0 likes
              Last Post cmtjoancolmenero  
              Started by lucasmelo152, 06-28-2021, 12:51 PM
              8 responses
              2,124 views
              0 likes
              Last Post Ymcapital  
              Started by Creamers, 04-27-2024, 05:32 AM
              11 responses
              69 views
              0 likes
              Last Post Creamers  
              Working...
              X