Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecution firing on primary series while orders are submitted on secondary series

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

    OnExecution firing on primary series while orders are submitted on secondary series

    Hi,

    In a MTF strategy, I'm submitting the orders on the secondary data series.

    Actually OBU is only running on the secondary data series, and then the orders are being submitted on the secondary data series, where I have explicitly set the barsInProgress in the order parameters.

    However, when the OnExecution event is fired, I'm noticing that the BarsInProgress is equal to 0. I have overridden everywhere the primary series, and yet the OnExecution is still being called on the primary series.

    Is this something normal?

    Thanks.

    #2
    Hello,

    That should not be anything to worry about, because the BarsInProgress value at the time OnExecution() is called is purely coincidental. OnExecution() is not called by a Bars object, but rather by an order, so the BarsInProgress could be anything when OnExecution() is called, and could even change within a single call to OnExecution(). This differs from OnBarUpdate(), which is called by a bars object. Testing BarsInProgress within OnBarUpdate() will tell you which Bars object called the method, but the same will not be true with OnExecution().

    Are you seeing anything weird going on with your actual executions?
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Thank you Dave. No I haven't seen anything weird, just wanted to have a better understanding.
      Your explanation is perfect. Thanks.

      Comment


        #4
        Hi,

        Following up on this subject, if I would like to know the timestamp and CurrentBar of when the order is executed, how do I do that?

        Time[0] and CurrentBar in the OnExecution() event are returning the datetime and current bar of the primary 5-min series, while the strategy and orders are running on the secondary tick series.

        Thanks.

        Comment


          #5
          Originally posted by silacitrader View Post
          Hi,

          Following up on this subject, if I would like to know the timestamp and CurrentBar of when the order is executed, how do I do that?

          Time[0] and CurrentBar in the OnExecution() event are returning the datetime and current bar of the primary 5-min series, while the strategy and orders are running on the secondary tick series.

          Thanks.
          For the time of the order, you can query the relevant IOrder.

          For the barNumber, the surest method will be to run a loop until you find the bar first bar whose time exceeds that of the IOrder.

          Comment


            #6
            koganam is correct. You might also consider using

            Code:
            Times[[I]int barSeriesIndex[/I]][[I]int barsAgo[/I]]
            and

            Code:
            CurrentBars[[I]int barSeriesIndex[/I]]
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Thanks Dave, forcing the barsSeriesIndex looks good.

              Comment

              Latest Posts

              Collapse

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