Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi timeframe synchronization issue

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

    Multi timeframe synchronization issue

    I am writing an indicator that has 3 min YM data as the main data and I've added 1 min data as the second timeframe.

    The issue I have is that the Highs and Lows of the minute data and 3 min data do not synchronize.

    I expect the high of one of the 1 minute bars and the low of one of the 1 min bars to be the same as the high and low of the 3 min bars but it is not. The following demonstrates the issue. The first shown # is BarsInProgress. 0 is 3min 1 is 1min. My indicator is failing due to this issue. How can I fix it?

    This data is for YM on 2/28/2013




    0: CurrentBar=260- Open[0]=14071- High[0]=14076- Low[0]=14054- Close[0]=14054
    1: CurrentBar=766- Open[0]=14065- High[0]=14068- Low[0]=14054- Close[0]=14054
    1: CurrentBar=767- Open[0]=14054- High[0]=14055- Low[0]=14048- Close[0]=14050
    1: CurrentBar=768- Open[0]=14050- High[0]=14051- Low[0]=14043- Close[0]=14051
    0: CurrentBar=261- Open[0]=14054- High[0]=14057- Low[0]=14043- Close[0]=14057
    1: CurrentBar=769- Open[0]=14051- High[0]=14057- Low[0]=14050- Close[0]=14057
    1: CurrentBar=770- Open[0]=14057- High[0]=14061- Low[0]=14055- Close[0]=14061
    1: CurrentBar=771- Open[0]=14061- High[0]=14064- Low[0]=14056- Close[0]=14059
    0: CurrentBar=262- Open[0]=14057- High[0]=14064- Low[0]=14053- Close[0]=14053
    1: CurrentBar=772- Open[0]=14059- High[0]=14060- Low[0]=14053- Close[0]=14053
    1: CurrentBar=773- Open[0]=14054- High[0]=14062- Low[0]=14054- Close[0]=14058
    1: CurrentBar=774- Open[0]=14059- High[0]=14059- Low[0]=14052- Close[0]=14056
    Last edited by afshinmoshrefi; 03-05-2013, 08:07 PM.

    #2
    afshinmoshrefi, so this script would be run from one 3 minute primary chart? And not a manual added 1 min in there?

    Comment


      #3
      The chart is a 3 minute YM chart. I've added 1 minute data to initialize as follows:

      protected override void Initialize()
      {
      Overlay= true;
      Add(PeriodType.Minute,1);
      }

      The data was printed to output with the following statement in onBarUpdate:

      Print(BarsInProgress+": CurrentBar="+CurrentBar+"- Open[0]="+Open[0]+"- High[0]="+High[0]+"- Low[0]="+Low[0]+"- Close[0]="+Close[0]);


      My issue is that I was expecting the High and Low of 3 minute bar to be synchronized with highs and lows of the corresponding 1 minute bar. at least 1 of 1min bar highs should match the 3 min and same with the lows but they are not. It seems that 1 min bars and 3 minute bars are out of sync!


      Afshin

      Comment


        #4
        I would suggest you print the series timestamp via Time[0] as well to know exactly which bar you're comparing to which one.

        NinjaTrader stamps the bar on the close of each candle, so for the price values to be contained in the finer series you would have to look up in your print output as this would relay the 'intrabar data' then.

        Comment


          #5
          That helped. The 3 min and 1 min bars are out of sync: the 3 consecutive 1 minute bars are distributed between 2 different 3 min bars.

          0:Time[0]=3/1/2013 7:15:00 AM: CurrentBar=260- Open[0]=13995- High[0]=13997- Low[0]=13993- Close[0]=13993
          1:Time[0]=3/1/2013 7:15:00 AM: CurrentBar=693- Open[0]=13994- High[0]=13994- Low[0]=13993- Close[0]=13993
          1:Time[0]=3/1/2013 7:16:00 AM: CurrentBar=694- Open[0]=13993- High[0]=13993- Low[0]=13989- Close[0]=13989
          1:Time[0]=3/1/2013 7:17:00 AM: CurrentBar=695- Open[0]=13989- High[0]=13989- Low[0]=13986- Close[0]=13989
          0:Time[0]=3/1/2013 7:18:00 AM: CurrentBar=261- Open[0]=13993- High[0]=13993- Low[0]=13986- Close[0]=13987
          1:Time[0]=3/1/2013 7:18:00 AM: CurrentBar=696- Open[0]=13989- High[0]=13990- Low[0]=13987- Close[0]=13987
          1:Time[0]=3/1/2013 7:19:00 AM: CurrentBar=697- Open[0]=13987- High[0]=13989- Low[0]=13984- Close[0]=13985
          1:Time[0]=3/1/2013 7:20:00 AM: CurrentBar=698- Open[0]=13985- High[0]=13985- Low[0]=13975- Close[0]=13976
          0:Time[0]=3/1/2013 7:21:00 AM: CurrentBar=262- Open[0]=13987- High[0]=13989- Low[0]=13975- Close[0]=13977
          1:Time[0]=3/1/2013 7:21:00 AM: CurrentBar=699- Open[0]=13976- High[0]=13978- Low[0]=13975- Close[0]=13977
          1:Time[0]=3/1/2013 7:22:00 AM: CurrentBar=700- Open[0]=13977- High[0]=13980- Low[0]=13976- Close[0]=13978
          1:Time[0]=3/1/2013 7:23:00 AM: CurrentBar=701- Open[0]=13978- High[0]=13982- Low[0]=13978- Close[0]=13981

          Comment


            #6
            Is This a Ninja Bug??

            There must be an issue with sync between 3 min and 1 min bars with Historical data.
            Please look at attached. The highlighted bars are the 3 min and 3, 1 min bars that correspond to each other. The last 1 min bar is reported too late and assignment of CurrentBars[0] is for the next bar.


            Is there a way I can fix the synchronization of 3min and 1min bars when looking at historicals?

            Thansks,

            Afshin
            Attached Files

            Comment


              #7
              Originally posted by afshinmoshrefi View Post
              There must be an issue with sync between 3 min and 1 min bars with Historical data.
              Please look at attached. The highlighted bars are the 3 min and 3, 1 min bars that correspond to each other. The last 1 min bar is reported too late and assignment of CurrentBars[0] is for the next bar.


              Is there a way I can fix the synchronization of 3min and 1min bars when looking at historicals?

              Thansks,

              Afshin
              ref: http://www.ninjatrader.com/support/f...ead.php?t=3572

              Comment


                #8
                This tutorial does not show how to fix the synchronization issue. the 1 min bars and 3 minute bars are not properly synchronized unless I'm missing something. Please look at the attached GIF and tell me if this behavior is expected.

                Comment


                  #9
                  Originally posted by afshinmoshrefi View Post
                  This tutorial does not show how to fix the synchronization issue. the 1 min bars and 3 minute bars are not properly synchronized unless I'm missing something. Please look at the attached GIF and tell me if this behavior is expected.
                  The example specifically talks about synchronizing the secondary barSeries. Heck, it is practically the title of the post.

                  Comment


                    #10
                    I don't see how to fix the synchronization issue. this tutorial explains how it should work. I think I understand it but 1 min bars are out of sync with 3 min bars by 1 bar. I don't understand how to fix that.

                    The GIF I've attached shows that minute bar series is out of sync with 3 min bar series. the first 2 min bars and 3rd minute bar are part of 2 different 3 min bars while they should be part of the same 3 minute bar. I can hack it in the code to get the indicator working but this just doesn't make sense.

                    Comment


                      #11
                      Originally posted by afshinmoshrefi View Post
                      I don't see how to fix the synchronization issue. this tutorial explains how it should work. I think I understand it but 1 min bars are out of sync with 3 min bars by 1 bar. I don't understand how to fix that.

                      The GIF I've attached shows that minute bar series is out of sync with 3 min bar series. the first 2 min bars and 3rd minute bar are part of 2 different 3 min bars while they should be part of the same 3 minute bar. I can hack it in the code to get the indicator working but this just doesn't make sense.
                      There is no GIF.

                      Comment


                        #12
                        Is this a bug with Ninja?!

                        This GIF shows the output of the 1min and 3min bars. I've highlighted the 4 bars which correspond with each other, however, Ninja reports them as part of 2 different 3 minute bars.
                        Attached Files

                        Comment


                          #13
                          Do all the calculations on BIP==1.

                          Comment


                            #14
                            Originally posted by afshinmoshrefi View Post
                            This GIF shows the output of the 1min and 3min bars. I've highlighted the 4 bars which correspond with each other, however, Ninja reports them as part of 2 different 3 minute bars.
                            What is the time of the very first 1-min bar on the chart?

                            Comment


                              #15
                              the first # shows BarsInProgress

                              0: is 3min bars
                              1: is 1min bars

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by cmoran13, 04-16-2026, 01:02 PM
                              0 responses
                              51 views
                              0 likes
                              Last Post cmoran13  
                              Started by PaulMohn, 04-10-2026, 11:11 AM
                              0 responses
                              31 views
                              0 likes
                              Last Post PaulMohn  
                              Started by CarlTrading, 03-31-2026, 09:41 PM
                              1 response
                              165 views
                              1 like
                              Last Post NinjaTrader_ChelseaB  
                              Started by CarlTrading, 04-01-2026, 02:41 AM
                              0 responses
                              100 views
                              1 like
                              Last Post CarlTrading  
                              Started by CaptainJack, 03-31-2026, 11:44 PM
                              0 responses
                              160 views
                              2 likes
                              Last Post CaptainJack  
                              Working...
                              X