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

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 nandhumca, Today, 03:41 PM
              0 responses
              4 views
              0 likes
              Last Post nandhumca  
              Started by The_Sec, Today, 03:37 PM
              0 responses
              3 views
              0 likes
              Last Post The_Sec
              by The_Sec
               
              Started by GwFutures1988, Today, 02:48 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              6 responses
              33 views
              0 likes
              Last Post ScottWalsh  
              Started by frankthearm, Today, 09:08 AM
              10 responses
              36 views
              0 likes
              Last Post frankthearm  
              Working...
              X