Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unexpected 'Close Position' orders

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

    #16
    worow,

    I do not see any instances where the order is greater than 1. If you look at the Close position log it is all quantities of 1. Remember, the close position will bring you flat. Then the reversal order will bring you 1 in the opposite direction.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      I thought these mesages indicated that a 5 lot was traded in the Spoo minis

      Order='65c268d4845f49efafcac0fbd75e88b2/Sim101' Name='Close position' New State=Filled Instrument='ES 03-09' Action=Sell Limit price=0 Stop price=0 Quantity=5 Type=Market Filled=5 Fill price=812 Error=NoError Native error=''Order='65c268d4845f49efafcac0fbd75e88b2/Sim101' Name='Close position' New State=Working Instrument='ES 03-09' Action=Sell Limit price=0 Stop price=0 Quantity=5 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''Order='65c268d4845f49efafcac0fbd75e88b2/Sim101' Name='Close position' New State=Accepted Instrument='ES 03-09' Action=Sell Limit price=0 Stop price=0 Quantity=5 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''

      Is that an actual 5 lot order or just a totalling?

      Comment


        #18
        Yes, you acquired 5 long in your ES. That is why the close position states 5. In order to reverse, it needs to close your position.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Great, I appreciate you helping me get to the bottom of this.

          Comment


            #20
            Unfortunately I'm running into this problem again. In my test code I only generate orders for 100 shares. In my execution log I frequently see fills for multiples thereof.
            If the strategy were working properly pairs of orders (one long one short in different underlyings) would be enter simultaneously and only 100 share per order.

            I only use EnterLong and EnterShort methods to generate orders. Any thoughts on why the larger orders are showing up would be appreciated. I've attached a log file with an example.
            Attached Files

            Comment


              #21
              worow,

              You need to check your positions. Remember when you try to go from being short to being long NT will automatically close your short position first. If you have a short position it will try to eliminate that position and then get you into your long position.
              Josh P.NinjaTrader Customer Service

              Comment


                #22
                I realize that the close positon message is generated when the sign of the position flips but I don't understand why orders larger than 100 are being submitted.

                My position should always be long and short the same quantity of shares. Everytime this error occurs the position gets out of balance. How can this occur? If I always submit pairs of orders in equal quanitites why would would the position get out of balance? The reason I'm focused on these "close position" orders is because the errors in position balance occur when they are generated.

                Comment


                  #23
                  This is something you need to debug out from your code. You are acquiring positions greater than 100 quite possibly because you keep submitting short orders despite already having short positions.

                  I suggest you use Print() in your code and just track your position size.

                  At the top of your OnBarUpdate just add:
                  Code:
                  Print(Time[0] + " Position: " + Position.MarketPosition + " Quantity: " + Position.Quantity);
                  Then just follow it in your Output Window.

                  Also, add TraceOrders = true into Initialize().
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    That must be whats happenning but I could use a hit as to where to look. If I am submitting multiple short orders I should also be submitting multiple long orders in other shares but I don't see the offsetting orders. I really like your product but I don't want to commit to it if I can't get to the bottom of this.

                    Comment


                      #25
                      Please see my edited previous post.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        What would be a good way to make my code wait for an order to fill before submitting another order?

                        Comment


                          #27
                          You can check the quantity before you submit an order then you can check and see when it has changed. Once the quantity has changed you know you have received some form of partial fill or filled from your order and then you can continue and submit other orders.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #28
                            I've been making use of the output window and Trace() method. Both imply that only 100 lot orders are being issued and orders are being submitted in pairs. However, the positions window in Control Center shows otherwise.

                            Comment


                              #29
                              Please use the print I suggested and you will find you are increasing your position quantity.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #30
                                Here's whats happening:

                                I am short 300 of share A.
                                Prices move to a trigger level and I submit a buy order for 100
                                NinjaTrader generates a "close position" "buy to cover" order for 300
                                NinjaTrader executes my original order to buy 100

                                Instead of being short 200 I am long 100. I don't know what is generating the buy to cover order for 300.

                                The two log messages are pasted below. All the program is suppose to do is reduce the short position by 100, not cover the short position and go long 100.


                                2/13/2009 14:29OrderOrder='da6a61af6f3e4979a667a3ff7ff51f4f/Sim101' Name='Buy 2 Sell 1' New State=PendingSubmit Instrument='A' Action=Buy Limit price=0 Stop price=0 Quantity=100 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''




                                2/13/2009 14:29OrderOrder='71b36738395040a9b8d1f64e1f1a0a25/Sim101' Name='Close position' New State=PendingSubmit Instrument='A' Action=BuyToCover Limit price=0 Stop price=0 Quantity=300 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                119 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                62 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                40 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                45 views
                                0 likes
                                Last Post TheRealMorford  
                                Started by Mindset, 02-28-2026, 06:16 AM
                                0 responses
                                82 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Working...
                                X