• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bug with unmanaged orders and exit on close

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

    bug with unmanaged orders and exit on close

    I've found that if an entry order is palced on the last bar of session when being flat with managed orders disabled and exit on close enabled, the entry order executes on the close of the of the last bar of the session resulting in a possition held over night.

    #2
    darckeen, is this a MultiSeries script and are you submitting orders to the primary series only at this point?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      darckeen, is this a MultiSeries script and are you submitting orders to the primary series only at this point?
      Yup its a multisereis single instrument strategy, the entry order is submitted to the primary bar series but on the secondary series update.

      Comment


        #4
        If you submitted to the primary series the end of session handling should've caught it - would you mind sending me your script for testing and looking into here?

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          primary instrument is SPY 5 minute

          Code:
           
          protected override void Initialize()
          {
          CalculateOnBarClose = true;
          this.ExitOnClose = true;
          this.Unmanaged = true;
          Add("SPY",PeriodType.Minute,30);
          }
          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          DateTime bartime = (DateTime)Times[BarsInProgress][0];
          if (bartime.Hour == 16 && BarsInProgress == 1) SubmitOrder(0,OrderAction.Buy,OrderType.Market,100,0,0,"","");
          }

          Comment


            #6
            darckeen,

            This is expected. You have both bars of the same instrument and as such ExitOnClose is only applicable to the primary series of the instrument. Since the secondary series is processed after the primary, you are submitting the order from the secondary which means the ExitOnClose logic was already done and over with at the time you submitted the order. This further means the order goes in after the fact and so as such you will indeed be in a position overnight with this strategy logic.
            JoshNinjaTrader Customer Service

            Comment


              #7
              Hello

              by searching for an answer i ran into this thread.

              (unmanaged approach)
              my question is when exit on close was the reason for executing how to track it in OnExecution(IExecution execution):
              if (execution=ExitOnCLose)???

              tx

              Comment


                #8
                Hello yeshe,

                Thank you for your post.

                The code would be the following:
                Code:
                if(execution.Name == "Exit on close")
                Patrick H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by xinepev, Today, 12:33 AM
                0 responses
                3 views
                0 likes
                Last Post xinepev
                by xinepev
                 
                Started by sun0781, Yesterday, 05:02 PM
                0 responses
                7 views
                0 likes
                Last Post sun0781
                by sun0781
                 
                Started by ronhb107, 09-12-2019, 10:09 AM
                4 responses
                42 views
                0 likes
                Last Post Mr.Trader  
                Started by rwilliam, Yesterday, 03:55 PM
                0 responses
                3 views
                0 likes
                Last Post rwilliam  
                Started by asmmbillah, Yesterday, 03:42 PM
                2 responses
                9 views
                0 likes
                Last Post asmmbillah  
                Working...
                X