Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitOnClose problem

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

    ExitOnClose problem

    I use a test and a live environment. Both connected to IB for data. My strategy uses the ExitOnClose with ExitOnCloseSeconds=30. Yesterday I had a Long position. The ExitOnClose was activated and the position was closed 30 seconds before the session ends on both my test and live environment. So far so good. This morning I opened both NT on live and test and enabled the strategy on bot systems. I noticed that on my Live system the last bar did not show the ExitOnClose signal anymore. On my testsystem it still does. So on my live system the current system is still open, this is not according how it should be because the settinsg are still the same for the ExitOnClose. It seems probbale that on the live system it is not signalled as that the session has ended. Could that be the problem? I noticed in the session manager on both system (live is using a live license of NT and the test is using a teslicence of NT) that there is a difference. On the test all sessions are noted using UTC and on the live system all sessions are noted using GMT. I use on both systems the US Equity RTH session template. Could this cause the difference? If so, how can I make sure I have the latest session templates?

    Look forward to your reply.
    Kind regards,
    Rene

    #2
    Hi Rene, which symbols are you trading here with the strategy and which NT7 build version would you run for the setups? Latest session / instrument definitions could be ensured to be included if you'd upgrade to our R11 release and then reset instruments under Tools > Options > Data.

    Are both systems setup in different timezones?

    Comment


      #3
      The symbol used is ^COMP (Nasdaq Composite Index). Both systems are using NinjaTrader 64-bit version 7.0.1000.11. Both systems are in the same timezone. I narrowed down the problem a little bit. On the live system where the ExitOnClose signal is missing I have done the following:

      I start NT and connect to Kinetick (first datavendor). If I enable to strategy the ExitOnClose signal is missing (only the ExitOnClose signal on the last bar is missing, previous ExitOnClose signals from previous session are displayed correctly). If I remove the strategy from the chart and insert the strategy again in the start with exactly the same parameters and if I then enable the strategy the ExitOnClose signal is now correctly displayed on the last bar.

      So by removing and reloading the strategy it shows the rigth signal, but that is not a nice workaround.

      The only difference I can see between the tow systems are the Windows system:
      The Live system is using Windows Vista Home Premium
      The Test system is using Windows 7 Home Premium

      I have also changed the data supplier from Kinetick to IB, but no difference.

      Look forward to your reply.

      Kind regards,
      Rene

      Comment


        #4
        Rene, thanks - would it be feasible for you to test this live on the other PC / OS tomorrow perhaps? As I would be interested in if this issue is tied to a specific setup used in your office or just whatever one is being used to deploy in realtime. There are some limitations in this regard with ExitOnClose behavior that are expected to be addressed in our next major platform update.

        Comment


          #5
          I will perform a test for this issue. If I have additional information I will post it. Do you have any guidelines what to look for in the test? It seems to be related to the last bar only.

          Kind regards,
          Rene

          Comment


            #6
            We wouldn't have any specific guidelines at this time. Please let us know the results tomorrow.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by Renejm View Post
              I use a test and a live environment. Both connected to IB for data. My strategy uses the ExitOnClose with ExitOnCloseSeconds=30. Yesterday I had a Long position. The ExitOnClose was activated and the position was closed 30 seconds before the session ends on both my test and live environment. So far so good. This morning I opened both NT on live and test and enabled the strategy on bot systems. I noticed that on my Live system the last bar did not show the ExitOnClose signal anymore. On my testsystem it still does. So on my live system the current system is still open, this is not according how it should be because the settinsg are still the same for the ExitOnClose. It seems probbale that on the live system it is not signalled as that the session has ended. Could that be the problem? I noticed in the session manager on both system (live is using a live license of NT and the test is using a teslicence of NT) that there is a difference. On the test all sessions are noted using UTC and on the live system all sessions are noted using GMT. I use on both systems the US Equity RTH session template. Could this cause the difference? If so, how can I make sure I have the latest session templates?

              Look forward to your reply.
              Kind regards,
              Rene

              I have had the same problem multiple times. For me, so far, as it messes with my Strategy, here is how I solve it. It is a cumbersome workaround, but I need to get my positions to reflect reality to my code.
              1. Verify with the broker that the position was indeed exited, and I am flat. (So far, fortunately, it has not happened that NT is telling me I am flat, but never actually send the exit order, so that I am in a position, which given my luck, would almost certainly be a losing position). Touch wood.
              2. Change the Session Template to "Use Instrument Settings". This, so far, always makes the "Exit On Close" show up.
              3. Change the Session Template, in my case, back to "CME US Index Futures RTH". The "Exit On Close" seems to stay valid, though on more than one occasion, I have had to repeat the process before getting the desired result.
              It seems to me that NT is just not recording the signal correctly in the Database.

              So it would seem that changing the Session Template, in this particular case forces processing past the actual close bar, so that NT is forced to reprocess the signal. I did think of raising a bug report, but I cannot reproduce the problem with any consistency, so I went looking for a workaround. And no, merely hitting F5 to reload the chart and Strategy does nothing to help! At least, not in my case.
              Last edited by koganam; 03-25-2013, 08:33 AM. Reason: Corrected punctuation.

              Comment


                #8
                I started a simple test for the ExitOnClose issue. I have the next problem.

                protected override void Initialize()
                {
                BarsRequired =
                200;
                Unmanaged =
                true;
                MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
                ExitOnClose =
                true;
                ExitOnCloseSeconds =
                30;
                }

                protected override void OnBarUpdate()
                {
                if (CurrentBars[0] < BarsRequired)
                return;

                if ((LastPositionLong == "FLAT") && Bars.BarsSinceSession > 5){
                LongTradeTag++;
                LastPositionLong =
                "LONG";
                SubmitOrder(
                0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", CurrentBar.ToString());
                }
                }

                protected override void OnExecution(IExecution execution)
                {
                if (execution.Order != null && execution.Order.OrderState == OrderState.Filled) {

                if (execution.Order.OrderAction != OrderAction.Buy) {
                LastPositionLong =
                "FLAT";
                }
                }
                }

                Enter long after 5 bars in new session and ExitOnClose. If I apply this to an instrument in a graph it opens the first position and execute the exit on close. OK. But in the second session no order is opened after 5 bars. It seems that ExitOnClose did not execute the OnExecution code correctly. I printed the execution.ToString() in the OnExecution statement. Seems to be ok. But if I Print the execution.Order.ToString() I get an error in the output window

                Error message: **NT** Error on calling 'OnExecution' method for strategy 'TestExitOnClose/2b17940cec42478cb32ccf6bb954f535': De objectverwijzing is niet op een exemplaar van een object ingesteld".

                The ExitOnClose did return this error. I have only 1 Dataserie in the chart and do not add any in the strategy. Any suggestion?

                Kind regards,
                Rene

                Comment


                  #9
                  Hello,

                  Unfortunately ExitOnClose will not cause the OnExecution to be called. A work around to this would be to custom code your own exit on close condition using Time





                  @Koganam: thank you for this information I will notify development with this.
                  LanceNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

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