• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Frequent time lapses in second-level input data...

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

    Frequent time lapses in second-level input data...

    Hello fabulous NT tech support people!

    I am developing a complex indicator that parses Level II data.

    I frequently see time lapses in my input data! I test in my code if Time[1] is more than one second behind Time[0] and my test code will frequently report gaps of 2,3,4 and even 5 seconds!

    The stock under consideration is 'AMD' and the data provider Kinetick with their LevelII data stream.

    This indicators has its 'Calculate' field to OnBarClose (not OnEachTick), and is the only one running and without a strategy (within the context of a normal real-time chart). On the downside it does process OnMarketUpdate() but I've already placed code in there to make it as efficient as possible (for example by returning early when the depth is too far from the strike price)

    Q1: Have you seen this happening with simple indicators?
    Q2: Do you think this happens because I take too long in OnMarketUpdate() (My code is based on the reference example you sent a couple months back)
    Q3: If you suspect it's my code loading the system too much, what should I reduce first?
    Q4: Is there some timing instrumentation I can implement in time-sensitive calls so I can self-detect if my code takes too long in time-critical areas? (e.g. taking too long in OnMarketDepth())

    Thanks!
    Last edited by JPPoulin; 02-26-2020, 03:05 PM.

    #2
    Hello JPPoulin,

    Thank you for your post.

    Is the secondary series that you're accessing with Time[1] a single tick series? What is the primary time frame?

    Could you provide a sample of how you're checking the times?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate, thanks for the early response

      Test code below:
      --------
      //== Perform safety checks on our time series (to see if there are gaps) ===
      if (CurrentBars[0] >= 2) {
      TimeSpan oTimeSpan_DeltaTimeFrame = Time[0] - Time[1];
      if (oTimeSpan_DeltaTimeFrame.TotalSeconds > 1) {
      CManager.Print1(string.Format("{0,22}: #WARNING: Skipped second bar. Delta seconds in Time[] series = {1}!", oTimeNow.ToString(), oTimeSpan_DeltaTimeFrame.TotalSeconds));
      }
      --------
      Output results in:
      -----------
      2/26/2020 3:57:22 PM: #WARNING: Skipped second bar. Delta seconds in Time[] series = 2!
      2/26/2020 3:58:10 PM: #WARNING: Skipped second bar. Delta seconds in Time[] series = 2!
      2/26/2020 3:58:48 PM: #WARNING: Skipped second bar. Delta seconds in Time[] series = 2!
      (many more)

      This is an indicator that does not have a secondary series. It runs solo own in a standard chart.

      Comment


        #4
        Hello JPPoulin,

        Thank you for your reply.

        This would be fairly normal for a 1 second data series. If there are no ticks during that second, no bar will be formed, and the next forming bar may be 2 or even more seconds later. This would very much depend on how volatile of a market you're looking at, but yes, entirely possible for you to get those prints. It's not actually lag, simply that there was no data during that time frame.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi Kate, thanks for your response.

          Studying the documentation for 'Calculate' it appears that OnBarUpdate() should be called regardless of if the price is the same or not (Calculate.OnPriceChange should do as you described)

          https://ninjatrader.com/support/help...sub=OnBarClose

          Are you saying that even the chart will show no bars if there is not a single tick in that second? (meaning no bar will be formed for that second and even with Calculate == OnBarClose that there would be no OnBarUpdate() called for tick-less seconds?

          Q: Is there a way to force the chart to form bars even when there are no underlying ticks for that bar?

          Thanks again.

          Comment


            #6
            Hello JPPoulin,

            Thank you for your reply.

            That is absolutely correct. Let's think about it this way. We have a bar at 00:00:01, because we have ticks coming in, but the market isn't very volatile. No ticks come in until after 00:00:03.000, so the next bar would be timestamped 00:00:04. No bars can be formed in the interim because there simply is no data. On Bar Update for the 00:00:01 bar would not run until the first tick of the next bar comes in between 00:00:003.000 and 00:00:03.999. There is no way to force the chart to form bars when no data is available.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hi Kate, thanks for the prompt response and useful example.

              Now I understand why there is no data sometime.

              It would be a good idea to place the example you wrote in the documentation for OnBarClose as that documentation implies that OnBarUpdate() should be called every time period.

              Thanks!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by MrSomebody, Today, 06:46 AM
              0 responses
              2 views
              0 likes
              Last Post MrSomebody  
              Started by catinabag, Today, 06:09 AM
              0 responses
              2 views
              0 likes
              Last Post catinabag  
              Started by Fiocco, Today, 05:59 AM
              0 responses
              5 views
              0 likes
              Last Post Fiocco
              by Fiocco
               
              Started by Perceivedshift, Today, 05:17 AM
              0 responses
              7 views
              0 likes
              Last Post Perceivedshift  
              Started by herbertmack, Today, 03:19 AM
              0 responses
              5 views
              0 likes
              Last Post herbertmack  
              Working...
              X