Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with automated close of market order

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

    #16
    Ok, i did not notice that exit orders required quantity size to be specified. I was only specifying it on entry. I can certainly save and specify it on exit also.

    I will let you know how it turns out.

    thanks

    Comment


      #17
      I feel defeated

      Now it's gotten crazy.


      I recently changed my script to maintain the size of the positioned that was opened, and use that position size to explicitly close the position via ExitLong. I close the exact amount that was originally opened.

      It usually works.


      However, yesterday at 3:58 my strategy called ExitLong on an open position of about 2807 shares. I had traceOrders turned on and noticed on the output window that the ExitLong order was entered with the correct sizing information.


      However, what was actually placed and executed at the broker was an order for exactly 900 less shares than the amount displayed in traceorders. Also, when I check the log and trace files, they also show the order being placed for the lesser, incorrect amount. Only the traceOrders information showed the correct position size on the exit call.

      I've since closed the output window and can't find the traceOrders output in any of the log files. As a result, I can't find anything now showing the discrepency between the two order amounts (the amount that was called in ExitLong vs what was actually generated and sent to the broker. Is TraceOrders output not saved anywhere?

      Any idea how an explicitly called exitlong position with an explicit quantity size would generate a close order with a totally different quantity size? If not, any guidance on how I could capture data that would help from a support standpoint?

      thanks

      Comment


        #18
        If you are closing a position you can just use ExitLong() without an explicit quantity. Remember, if you have a single EnterLong(), do NOT call ExitLong() twice with separate quantities to try to exit the whole position. If you are trying to scale-out you need to scale-in first with separate entry orders.
        Josh P.NinjaTrader Customer Service

        Comment


          #19
          Hi Josh,

          My situation is really simple. I call enter long with a quantity to enter the position.

          Originally, I was just calling exit long without a quantity to exit. The problem is, the strategy was only exiting part of the position about half of the time. I don't know why, but thats what it was doing pretty consistently.

          So, at the recommendation here, i changed my ExitLong to use a quantity variable, based on the original entry quantity. I thought that fixed it, but it was apparent yesterday that it is still only exxiting part of the positions. Even when I explicitly called ExitLong for the full quantity, it is only issuing an order to my broker for a part of the quantity.

          The only thing complex about my strategy is that it is heavily multi-instrument and multi-timeperiod. But, the entries and exits are just simple, one time orders using EnterLong and ExitLong.

          Obviously, it being so unreliable at exiting positions is a killer. I'd be glad to gather whatever data is necessary to help solve the problem -- because my use of EnterLong and ExitLong is so simple, I'm at a bit of a loss.

          Thanks

          Comment


            #20
            Hi bridenour, which order handling setting do you use under Tools > Options > Strategies > NinjaScript ? Please try 'ByStrategyPosition' here.

            Comment


              #21
              I did switch it to "By Strategy Position" when you recommended it a couple of days ago. The problem occurred yesterday anyway.

              Comment


                #22
                bridenour,

                We are going to need TraceOrders = true output, log files, and trace files as well as a simple as possible, reproducible scenario.
                Josh P.NinjaTrader Customer Service

                Comment


                  #23
                  When it happens again, i will copy the traceOrders output and send it in along with the log files. It will demonstrate the problem.

                  At this point, I don't have a reproducible case other than to say it happens occasionally when trading live.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  104 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  52 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  34 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  38 views
                  0 likes
                  Last Post TheRealMorford  
                  Started by Mindset, 02-28-2026, 06:16 AM
                  0 responses
                  74 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X