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

Partial fills Qty orders don't match with its Stop Qty order

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

    Partial fills Qty orders don't match with its Stop Qty order

    Hi Ninjas,

    This is the event. When the Scrip must go Long, very often the BUY order is filled by parts. The Script supposedly must open immediately its respective Stop order with the same quantity of the Long position, however I watched that very often the Stop quantity order is lower that the total position. This Stop Qty matchs with the quantity of the last partial filled, then I have a complete Long position with an uncompleted Stop order working.

    Obviously I've set the script that the Stop order is trigger just when the Long position is totally filled, but still. Other note is that I've selected as Stop and Target submission: ByStrategyPosition, it should work well, so :

    How can I solved this?
    Last edited by pstrusi; 12-07-2013, 03:28 AM.

    #2
    Hello pstrusi,

    How are you placing your Stop Orders?
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi Jc,

      This is the module which manages the Stop order:

      Code:
      if (longOrder != null && longOrder == execution.Order)			
      			{					
      				if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))		
      				{				
      					sOrder = ExitLongStop(0, true, 100000, Low()-20* TickSize, "stop", "long entry");	
      					if (execution.Order.OrderState != OrderState.PartFilled)	
      					{	
      						longOrder = null;
      					}	
      				}		
      			}
      Thanks

      Comment


        #4
        Pstrusi,

        Are you sure this code compiles?

        sOrder = ExitLongStop(0, true, 100000, Low()-20* TickSize, "stop", "long entry");

        The Low() - 20 * TickSize should generate an error.

        However, have you tried submitting the order using the part filled quantity rather than the 100,000?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Pstrusi,

          Are you sure this code compiles?

          sOrder = ExitLongStop(0, true, 100000, Low()-20* TickSize, "stop", "long entry");

          1. The Low() - 20 * TickSize should generate an error.

          2. However, have you tried submitting the order using the part filled quantity rather than the 100,000?
          Hi Cal,

          1. Yes, a mistake, that was a typo writing it here, but actually is Low[0]

          2. No, I have not. But why the order doesn't fill if the quantity is fix in 100.000 ?
          I'll try later to do what you suggest anyway.

          Comment


            #6
            Pstrusi,

            The managed approach with exit orders will exit that amount you set unless your open positions is less than that value.

            I.E.
            If I submit an entry order with a quantity of 1 and then exit order with a quantity of 2, only 1 contract will get filled from the managed handling.

            The script will enter the first contract and the second will get ignored due to no position exists to exit.

            With your example, if you submit an order with a quantity of 100,000 and your part filled was for only 50,000.
            Then only 50,000 will be submitted and the rest will be ignored.

            Let me know if I can be of further assistance.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the explanation Cal, what you say is logical here:

              If I submit an entry order with a quantity of 1 and then exit order with a quantity of 2, only 1 contract will get filled from the managed handling.
              But this doesn't make any sense:
              With your example, if you submit an order with a quantity of 100,000 and your part filled was for only 50,000.
              Then only 50,000 will be submitted and the rest will be ignored.
              Why a remaining partially filled entry order, that eventually might be filled later, doesn't trigger its correspondent Stop loss order quantity increase?
              Last edited by pstrusi; 12-09-2013, 02:43 PM.

              Comment


                #8
                Pstrusi,

                They you have it setup currently with the logic and signal names in the OnOrderUpdate(), when you get the full filled entry order it will resubmit the ExitLongStop with the adjusted values.

                With the managed approach this is modifying the stop order to the correct quantity that your entry order has been filled for.

                Another example.

                Let's say that I placed a EnterLongLimit() with a signal name.
                I then want to adjust that limit value because my market has moved away.
                My condition will detect this and resubmit the same EnterLongLimit() with the same signal but with the new values. This will adjust my previous order to the new values.

                Let me know if this helps.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks for this useful suggestion, I'm sure it will work

                  Comment


                    #10
                    Hi Cal,

                    By the way, I had posted last week regarding this issue the following thread:

                    Ninjas, I got a confusion here trying to know which situation is the correct.

                    Reading the part regarding when to submit StopLoss orders ,using either OnOrderUpdate() or OnExecution() , like is shown on the help guide:


                    I'm kind of confused with this:

                    CRITICAL: If you want to drive your strategy logic based on order fills you must use OnExecution() instead of OnOrderUpdate(). OnExecution() is always triggered after OnOrderUpdate(). There is internal strategy logic that is triggered after OnOrderUpdate() is called but before OnExecution() that can adversely affect your strategy if you are relying on tracking fills within OnOrderUpdate().
                    and this:

                    If you are relying on the OnOrderUpdate() method to trigger actions such as the submission of a stop loss order when your entry order is filled ALWAYS reference the properties on the IOrder object passed into the OnOrderUpdate() method.
                    Which method is the right for submit Stop orders?

                    As you suggest, it seems that the method OnOrderUpdate() is the correct for Stops orders submission

                    I'll try this as soon as I can.

                    Thanks

                    Comment


                      #11
                      Pstrusi,

                      Again, this will depend on how you want to drive your strategy's logic.

                      If you do end up using OnOrderUpdate(), then please note that you will need to use the IOrder properties to correctly identify the fills.


                      Let me know how the testing goes.
                      Cal H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                      4 responses
                      541 views
                      0 likes
                      Last Post PaulMohn  
                      Started by GLFX005, Today, 03:23 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post GLFX005
                      by GLFX005
                       
                      Started by XXtrader, Yesterday, 11:30 PM
                      2 responses
                      11 views
                      0 likes
                      Last Post XXtrader  
                      Started by Waxavi, Today, 02:10 AM
                      0 responses
                      7 views
                      0 likes
                      Last Post Waxavi
                      by Waxavi
                       
                      Started by TradeForge, Today, 02:09 AM
                      0 responses
                      14 views
                      0 likes
                      Last Post TradeForge  
                      Working...
                      X