Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Instrument Sequencing

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

    Multi-Instrument Sequencing

    I am developing a multi-instrument strategy. I have defined the primary bars object as the instrument I want to trade and the additional bars object is used to determine when to trade.

    The question I have is in regards to backtesting. In my strategy both instruments use daily bars, and I need to insure that both instruments have been updated for the daily close. Can I be sure that OnBarUpdate for bars object 0 will be complete before OnBarUpdate for bars object 1, since I need both bar objects to be updated for that date before running my code?

    If this is not the case and I can't be sure which bars object updates first, how can I handle this in the code?
    Last edited by Double Bogie; 11-03-2012, 02:22 PM.

    #2
    If these are both Daily series and come from the same provider, they should update at the same time.

    However, you can control when the script is updated by using BarsInProgress filters.

    Please see our Help Guide on this property for more information:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Matthew,

      Thanks for your reply.

      It has not been my experience that both bars objects are updated at the same time. One updates first and any code following if (BarsInProgress == 0) will be executed when bars object 0 updates. Any code following if (BarsInProgress == 1) will be executed when bars object 1 updates.

      But if I put my code following if (BarsInProgress == 1) and bars object 1 updates first, then my code which is referencing bars object 0 will be out of sync, since it has not updated to the current date yet.

      I had this problem in my code. How do you insure that bars object 0 updates first?

      Comment


        #4
        How are you confirming that the objects are not updating at the same time?
        MatthewNinjaTrader Product Management

        Comment


          #5
          My algorithm to enter and exit trades is a function of the bars object 1. The objects traded were in bars object 0. I noticed that some equities trade dates were off by one day occasionally.

          I used print statements looking at bar counts and it seemed the cause was that the bars objects were being updated in a different order on these occasions, otherwise all of my trade dates would have been the same regardless of the equity.

          Comment


            #6
            I see- would you be able to provide an example script in which this is occurring?
            MatthewNinjaTrader Product Management

            Comment


              #7
              Originally posted by Double Bogie View Post
              Matthew,

              Thanks for your reply.

              It has not been my experience that both bars objects are updated at the same time. One updates first and any code following if (BarsInProgress == 0) will be executed when bars object 0 updates. Any code following if (BarsInProgress == 1) will be executed when bars object 1 updates.

              But if I put my code following if (BarsInProgress == 1) and bars object 1 updates first, then my code which is referencing bars object 0 will be out of sync, since it has not updated to the current date yet.

              I had this problem in my code. How do you insure that bars object 0 updates first?

              If I remember NT_Brett or NT_Bertrand (sorry, don't remember who), mention there is no guarantee with this type of stuff. (But they were talking intraday I believe). I'm not sure how you could expect BIPs for daily to go 0,1,2,3,4... and as you mentioned, you haven't seen this.

              It will probably get messy, but you could add some logic to wait for BIP=0 to fire(and then check if BIP=1/2/3) has fired and do conditional logic).

              Comment


                #8
                Thanks sledge. I was trying to determine if NT is supposed to update BIP's in order if the bars have the same ending time. I couldn't find anything about this in the help files.

                Since that doesn't seem to be the case, I was hoping someone who had encountered this problem before might have an elegant solution to the issue.

                Comment


                  #9
                  Hello Double Bogie,
                  So that I can replicate the scenario, can you tell me what instruments you are backtesing.

                  Also can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

                  Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

                  I look forward to assisting you further.

                  *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by Double Bogie View Post
                    Thanks sledge. I was trying to determine if NT is supposed to update BIP's in order if the bars have the same ending time. I couldn't find anything about this in the help files.

                    Since that doesn't seem to be the case, I was hoping someone who had encountered this problem before might have an elegant solution to the issue.
                    I found the thread I remembered reading...

                    Comment


                      #11
                      Joydeep, I have sent you toy code that exhibits the problem.

                      Comment

                      Latest Posts

                      Collapse

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