Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Flatten Position

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

    #16
    In the first filled I only submit stop1 and stop2 because the position quantity is only 3. So I submitted 2 for stop1 and 1 for stop2. Now seconds later the market filled the remaining 2 contracts. So as I said in my stop management I have this setup stop1 = 2, stop2 = 2, and stop3 = 1, that makes 5 contracts. My question is how to amend the quantity of my submitted stop2? Because I only submit 1 on it on the first filled. So that I could still maintain my stop management setup. I could not submit stop3 with the remaining 2 contracts filled because it will not follow my stop management setup.

    Comment


      #17
      Hi edward_bell,

      I understand now.

      As long as stop 2 has not filled, you can re-submit it with a quantity of 2 to amend it.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Ok so I will just use the ChangeOrder() method on it right?

        Comment


          #19
          Hi edward_bell,

          You are correct.

          Because the quantity is changing you will need to use change order.

          http://www.ninjatrader.com/support/h...hangeorder.htm

          Let me know if you have any trouble using this.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            What if filled price of the 2 remaining contracts is different by a tick from the filled price of the 3 contracts?

            Comment


              #21
              Hello edward_bell,

              That can and does happen.

              NinjaTrader provides a Position.AvgPrice. This would be the average entry point.

              Lets say you enter two orders. One fills at 100. The other fills at 120. NinjaTrader would then give a Position.AvgPrice of 110.

              Below is a link to the help guide on Position.AvgPrice.
              http://www.ninjatrader.com/support/h...7/avgprice.htm
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22
                So in my previous case what will happen to my stop2? I could not amend it because it has different filled price.

                Comment


                  #23
                  Originally posted by edward_bell View Post
                  So in my previous case what will happen to my stop2? I could not amend it because it has different filled price.
                  The fill price of an order has nothing to do with the Stop price of the protective order. If you want to use the fill price to calculate the stop price, then just use it. The price at which you issue the stop is the price at which you issue the stop, whether initially, or as adjusted.

                  Comment


                    #24
                    Hello edward_bell,

                    Are you not able to amend the order using ChangeOrder?

                    I am currently using the following line to amend stop1 to 5 ticks below entry successfully.

                    ChangeOrder(stop1, 1, 0, Position.AvgPrice - 5 * TickSize);

                    Attached is the full code.
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      SubmitOrder Using "Buy" vs "BuyToCover"

                      Hi ChelseaB,

                      I notice in all your attached examples using Unmanaged mode, you have this code,

                      Code:
                      else if (Position.MarketPosition == MarketPosition.Short)
                      {
                          SubmitOrder(0, OrderAction.Buy, OrderType.Market, Position.Quantity, 0, 0, "", "exit");
                      }
                      When you are short, shouldn't you use OrderAction.BuyToCover?

                      I presume they both end up doing the same thing because of OrderType.Market, but,
                      wait, uh ... hmm, aren't they both going to do exactly the same thing all the time for
                      all order types?

                      So, what's the difference in behavior between using "Buy" and "BuyToCover"?
                      Does it depend upon the exchange or something?

                      Thanks

                      Comment


                        #26
                        Hello bltdavid,

                        Yes, BuyToCover should be used here.

                        For some brokerages that would make a difference. (For the Sim101 it will not)

                        I've remade the export with that change.
                        Attached Files
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Edward, maybe this is too late, but in case it can be helpful for you, I'd suggest to set your stops-orders from other method:

                          Code:
                          protected override void OnPositionUpdate(IPosition position)
                          		{
                                               // detects what the new position is
                                               // If new position cancel old stops order and submit the one accordingly
                                               // if it's till same position with different quantity: change the order accordingly
                          }

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          84 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          47 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          29 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          32 views
                          0 likes
                          Last Post TheRealMorford  
                          Started by Mindset, 02-28-2026, 06:16 AM
                          0 responses
                          67 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Working...
                          X