Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsFirstTickOfBar big problem with additional dataseries

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

    IsFirstTickOfBar big problem with additional dataseries

    Hi,

    In my indicator I use two data series. The main dataseries is a "mini" market instrument and the additional dataseries is the "normal" market instrument..
    In all the code I use BarsArray[x] , Closes[x][x], Opens[x][x], etc to guarantee the data comes from the right dataseries.
    The problem we found and confirmed repeatedly is that for some reason the main dataseries ("mini" market instrument) first tick arrives with substantial delays in comparation with the addtional dataseries ("normal" market instrument) first tick, even though both show the same timestamp.
    This delays cause problems in calculations under IsFirstTickOfBar because seems that IsFirstTickOfBar does not discriminate if the first tick comes from the main dataseries or from the additional dataseries.

    For example, suposing main dataseries last bar number is 100 and we have a new first tick:

    if (IsFirstTickOfBar)
    {
    variableX = CurrentBars[0]
    }

    variableX should be = 101, but as the the main dataseries instrument first tick still does not arrived variableX will be = 100 again.

    This problem was tested in real time and in market replay with same results.

    Please could you give me some idea to solve this?

    Kind Regards,

    Marcos




    #2
    Hello superg3,

    IsFirstTickOfBar is true for the first tick of a new bar for that specific BarsInProgress. For example if the primary series is 1 minute, and the secondary is 15 seconds, there would be 3 times the secondary series has a print while the primary series does not.

    The reverse of this would also be true.

    To confirm, you are reporting that IsFirstTickOfBar is true when the tick is not the first tick of that specific BarsInProgress?

    Or are you stating that you are expecting a tick before it was received?
    (There is no guarantee on the order of when ticks will be received. The bar will be closed as soon as a tick is received after the time the bar is meant to be closed for that specific BarsInProgress.)

    Once confirmed, I will make a test script to test.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea B.,

      the primary series is FDXM (Future DAX Mini) 1 minute, and the secondary is FDAX (Future DAX) 1 mininute.
      I suppose I should expect the new bar first tick of both series arrive at the same time (or almost).
      But Yes, I'm reporting that IsFirstTickOfBar is true when secondary series first tick arrived and primary series still not. To be sure I tested it in different machines in different locations.
      I tested it in real time adding some lines to the script like:
      ...
      if (IsFirstTickOfBar)
      {
      if (Times[1][0].Ticks > Times[0][0].Ticks);
      {
      Alert(.......);
      }
      }

      Click image for larger version  Name:	photo_2019-07-12_11-40-59.jpg Views:	1 Size:	36.6 KB ID:	1064039


      I also compared the delays using variableX = 600000000 - (Times[1][0].Ticks - DateTime.Now.Ticks);

      Click image for larger version  Name:	photo_2019-07-12_11-55-31.jpg Views:	1 Size:	32.3 KB ID:	1064040








      Last edited by superg3; 07-14-2019, 08:17 PM.

      Comment


        #4
        Hello superg3,

        No, with two different instruments there is no guarantee which tick will be processed first. It is all event driven.

        However, to confirm this you would need to print the timestamp of each tick and the BarsInProgress.

        IsFirstTickOfBar can only be found while that BarsInProgress is running OnBarUpdate with a data update. It cannot be found for any other BarsInProgress at that time.

        The information you have provided is not showing whether or not BarsInProgress is only true for the first tick of the secondary series (regardless of whether it is true for the primary series as the two are not related).
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea B.,

          I understand you, due my poor English maybe Im not able to explain myself better.
          Both instruments show the same timestamp but primary series new bar first tick allways arrives delayed. What I need is to find a way to force IsFirstTickOfBar to wait for primary series first tick and exclude secondary series first tick.

          Click image for larger version  Name:	Captura.JPG Views:	1 Size:	253.5 KB ID:	1064092


          this does not solve the problem:

          if (BarsInProgress == 0)
          {
          if (IsFirstTickOfBar)
          {


          or

          if (BarsInProgress == 0 && IsFirstTickOfBar )
          {
          Last edited by superg3; 07-15-2019, 09:45 AM.

          Comment


            #6
            Hello superg3,

            The IsFirstTickOfBar is independent for each series with a different instrument.
            The secondary can have the IsFirstTickOfBar before the primary, and the primary can have the IsFirstTickOfBar before the secondary.

            Its possible that one of them has higher volume and is producing ticks more rapidly than the other and more often updates first.

            Below is a link to a video that demonstrates OnBarUpdate triggers with IsFirstTickOfBar for each instrument series independently.
            https://drive.google.com/file/d/140q...w?usp=drivesdk
            Last edited by NinjaTrader_ChelseaB; 07-15-2019, 09:57 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea B.,

              Thanks for the video, I fully understood the demonstration. At this point and as some of my script calculatios depends of both series, the only solution I see is to add extra code in my script under IsFirstTickOfBar to have different behaviours depending if (Times[1][0].Ticks > Times[0][0].Ticks);.

              Thank you for your assistance.

              Kind regards,

              Marcos.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              597 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              343 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
              556 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              555 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X