Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators using multiple instruments/timeframes - cont'd

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

    Indicators using multiple instruments/timeframes - cont'd

    Hi there,

    I am building 2 indicators, both multi-instruments/multi-timeframes.

    Indicator A provides some basics services, used by Indicator B (they are both supposed to be working off the same instruments/timeframes). As a result, Indicator B uses Indicator A.

    Although the timeframe 0 stays synchronized between A & B, it appears that the timeframe 1 gets called randomly for A, several bars in advance of what Indicator B sees of that timeframe 1.

    Is there a way to ensure that A & B will see each bar of timeframe 1 in a synchronized manner?

    Thanks in advance
    Dominique

    #2
    Hi Dominique, do you see for backtesting or realtime testing? Which Instruments and series are you working with here in your scripts? Do you see this on the bars objects updates directly or a custom dataseries you use for calculations? Those would need to be synched to run on another index other than the primary - http://www.ninjatrader.com/support/f...ead.php?t=3572

    Comment


      #3
      Hi Bertrand,

      I am on MarketReplay at this time, and I see that lack of synchronization happening while going through the Historical part of the chart. I have not checked the real-time behavior, as the historical desynchronization is a non-starter.

      I use CL 04-13 100-vol as TF-0 and CL 05-13 100-vol as TF-1. I have been testing specifically with a CL 04-13 100-vol chart set to have 3 days of data, I start MarketReplay on March 18, 2013 at 6:30pm (and pause it at that point).

      It works perfectly for a standalone indicator, however as soon as Indicator B uses indicator A, both of them being dual-timeframe, the desynchronization of TF-1 is there.

      It is pretty easy to reproduce, just print in each indicator the Indicator name, BarsInProgress, CurrentBar, Time[0] and see what it does when Indicator B uses Indicator A.

      I can strip everything off and just provide a barebone example if that can help.

      Cheers
      Dominique

      Comment


        #4
        Hi dom993,

        Bertrand is out of the office for the evening but I would like to test and assist you with this script/inquiry.

        I would like you to provide this stripped down version of the indicators that is able to reproduce this. It will help direct me to the issue quickly.

        Please either attach the file to your next post, or if you would like to keep the script private, send an email with this file attached to support[at]ninjatrader[dot]com. In the body of the email please write Attn: Chelsea #821580.

        Once received I will try and reproduce the results you have produced.


        I look forward to working with you further.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea / Bertrand

          See attached.

          Regards,
          Dominique
          Attached Files

          Comment


            #6
            Hello dom993,

            I wanted to let you know I have imported the scripts and am doing some testing.

            I will be responding with my results after I have had a chance to review.

            I appreciate your patience.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Any update ?

              Comment


                #8
                Hello dom993,

                I have done some testing and here's what I think I've found.

                First, I'm curious by what you mean by "as soon as Indicator B uses indicator A". I took this to mean you have used indicator A as the input series for indicator B in the indicator parameters on the chart. This is how i've been doing my testing.

                Looking at the results that I get I am not quite sure this is what you mean. When I use your indicators there is no values being set by indicator A. This means that the dataseries being passed to indicator B contains the right amount of bars but each bar is empty. The times do not match because indicator B is being supplied an empty data series.

                Please, let me know how you are adding indicator A to indicator B.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea,

                  Of course, the indicators that I sent you do not any processing, aside from printing to the Output window what's going on, which is enough to see that several bars from TF-1 are processed by Indicator A before Indicator B gets to see the 1st of these bars.

                  It is easy to understand that if Indicator B was using the current-bar value from indicator A, it would be using a value "in the future" (compared to the bar Indicator B is processing).

                  I sent you the code, there is really nothing more to it.

                  Regards
                  Dominique

                  Comment


                    #10
                    Hello Dominique,

                    How are you adding indicator A to indicator B?

                    I think perhaps I may have misunderstood this step. I am getting different times for the same bars using your code. But I would expect this as its printing the time of an empty bar.

                    For every bar of Indicator B I get the following result:
                    Indicator B TF# 0 CurrentBar 622 @ 1/1/1800 12:00:00 AM

                    This is what prints for an empty bar.

                    I am not really understanding the issue because I do not think I am reproducing the issue correctly.

                    So, how are you adding indicator A to indicator B; as in what steps do you take to add A to B?


                    I look forward to your reply.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chelsea,

                      Create a CL 1000-vol chart.

                      Load Indicator_B on it ; as you are doing this, type "ES 06-13" as its ZSecondTFInstrument parameter.

                      Indicator_B is now multi-instrument/TF, and in its OnBarUpdate() it calls Indicator_A.Update( BarsArray[0], ZSecondInstrument ), which as a result is also multi-instrument/TF, and uses the exact same TFs as Indicator_B.

                      (in a real application, Indicator_B would just use values from Indicator_A, doing that that gets Indicator_A.Update() to get called, since I don't really care using anything out of Indicator_A in this example I have simplified it to the max and used Update() directly)

                      You'll see in the Output window mostly TF#1 prints, because ES has about 10-times more volume than CL (and from 2:30pm to 4:15pm EST, way more than that).

                      When you look at the sequencing of those TF#1 calls, you'll see that Indicator_A gets to see a large number of TF#1 bars all at once, before Indicator_B gets to see any of these. The correct sequencing would have Indicator_A see ONE bar then Indicator_B see that same bar, etc.

                      I hope this will help you reproduce & understand the problem.

                      Regards
                      Dominique

                      Comment


                        #12
                        Hello Dominique,

                        After doing some testing I think I have identified the issue.

                        The Days to load value is not being shared with Indicator A because it is being supplied a dataseries.

                        Removing the dataseries from the Indicator A update call has allowed the script to print bars one for one.

                        For example:
                        Indicator_A( ZSecondTFInstrument ).Update();


                        Please let me know if this does not resolve your inquiry.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chelsea,

                          I don't think this fixes the issue ... to the contrary, it adds to it. Let me explain:

                          - by using Indicator_A( BarsArray[0], ZSecondTFInstrument ) I was guaranteeing that Indicator_A would use Indicator_B TF#0 as its own TF#0

                          - if you remove the reference to BarsArray[0], then what happens is that Indicator_A is called using the current timeframe as input - as a result, you are really now executing 2 distinct instances of Indicator_A, one using Indicator_B TF#0 as primary dataseries, and another one using Indicator_B TF#1 as primary dataseries.

                          On top of that, the synchronization issue isn't resolved as the attached screenshot can attest.

                          Regards
                          Dominique
                          Attached Files

                          Comment


                            #14
                            Hello Dominique,

                            I wanted you to know that I am still working on this. I have been able to reproduce your results and am understanding the problem.

                            I am still working on finding the cause and creating a solution.

                            I appreciate your patience.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Dominique,

                              So after doing some edits to make all the code in this supported code, I have changed the indicator to only update Indicator A for Indicator B's BarsInProgress 0.

                              Also, the indicators have been renamed without the underscore that you may import these along side of your originals.

                              I have also changed the added dataseries of both indicators to a 2 minute interval. This is so i could test using the same instrument for the primary and secondary dataseries. (To conserve memory if an instrument with the same interval is added twice there will only be 1 dataseries).

                              Try adding Indicator B to a CL 06-13 1 minute chart. You will see the current bar and time stamps are matching.

                              Next, add Indicator B to a ES 06-13 2 minute chart. The current bar and time stamps match until there are missing bars on the ES. (If data is not received in that 2 minute period a bar will not be created).

                              Also, the session templates can also cause this data to mis-align. You will need to be comparing two instruments that trade over the same hours and use the same session template.


                              Please let me know if this demonstration does not provide you with the information you need.
                              Attached Files
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

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