Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 frankthearm, Yesterday, 09:08 AM
              14 responses
              47 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by gentlebenthebear, Today, 01:30 AM
              2 responses
              13 views
              0 likes
              Last Post gentlebenthebear  
              Started by Kaledus, Today, 01:29 PM
              3 responses
              9 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by PaulMohn, Today, 12:36 PM
              2 responses
              17 views
              0 likes
              Last Post PaulMohn  
              Started by Conceptzx, 10-11-2022, 06:38 AM
              2 responses
              56 views
              0 likes
              Last Post PhillT
              by PhillT
               
              Working...
              X