Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A possible bug with exit on close?

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

    A possible bug with exit on close?

    I run a strategy that does exit on close. Last night it exited before the close. This morning I stopped my strategy and reran it. Before the open it had a "virtual" open position which never got closed. Now my strategy thinks it has an open position so it won't enter any new positions. I have wait until flat set to be true but I'm not sure that matters. It seems I'm stuck until my strategy will stop out.

    Any ideas?

    #2
    Hi cunparis, thanks for your post - at which time was the exit order submitted? To debug this it would be best to use TraceOrders = true in the Initialize() - http://www.ninjatrader-support.com/H...aceOrders.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Hi cunparis, thanks for your post - at which time was the exit order submitted? To debug this it would be best to use TraceOrders = true in the Initialize() - http://www.ninjatrader-support.com/H...aceOrders.html
      The order was exited yesterday 30 seconds before close. That works.

      The problem is the strategy thinks it hasn't exited when I rerun it. I presume this is because the last bar of yesterday isn't closed until the first bar of today. Something like that.

      Comment


        #4
        Hi cunparis, on which instrument and session times are you running this?

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Hi cunparis, on which instrument and session times are you running this?
          ES using RTH (9:30 - 4:00 EST)

          Comment


            #6
            Thanks, I also suspect you see this because as you restarted this morning the last bar from yesterday was still open, thus leaving you with a virtual position if the Mar****nClose did not trigger. So to debug this you would need to rerun this with the TradeOrders enabled and check the output window if it triggered again as you did the reload.

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Thanks, I also suspect you see this because as you restarted this morning the last bar from yesterday was still open, thus leaving you with a virtual position if the Mar****nClose did not trigger. So to debug this you would need to rerun this with the TradeOrders enabled and check the output window if it triggered again as you did the reload.
              I'm not sure what you mean by rerun, this happened with live trading with real money.

              Fortunately my strategy didn't trigger today so I didn't miss a trade but I'm quite sure this is a bug.

              Comment


                #8
                cunparis,

                You need to reproduce this with TraceOrders or else we have no information to advise you on.

                As you rerun your strategy in the you will likely not receive an Exit on Close order because your closing bar has not closed. Only TraceOrders will reveal what is happening.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  cunparis,

                  You need to reproduce this with TraceOrders or else we have no information to advise you on.

                  As you rerun your strategy in the you will likely not receive an Exit on Close order because your closing bar has not closed. Only TraceOrders will reveal what is happening.
                  It didn't close tonight either. It's never going to close. The only solution I can think of is to save the strategy to a new name and run it.

                  Have you tried reproducing it? It should be pretty easy. Just enter on open and let it close on exit. Then stop the strategy after hours and run it again and see it has the virtual position that doesn't close.

                  You don't even have to wait until 4pm just use a session time from 9:30 to 10:00.

                  Comment


                    #10
                    cunparis,

                    Please run with TraceOrders = true. As stated, when you stop your strategy and restart you are now in backtest mode. This is NOT the same as real-time. The last bar has not closed and as such you will likely NOT receive any Exit on Close till that bar closes. Only with TraceOrders = true will you know what is going on. Please use it.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    647 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    369 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    108 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    572 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X