Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsFirstTickOfBar missing bar data

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

    IsFirstTickOfBar missing bar data

    Hello There

    I created a simple script that prints the bar time on every first tick of bar recieved.
    however it seems for some reason this IsFirstTickOfBar does not work for me or it is skipping bars when there is a gap.


    MyScript.
    if (IsFirstTickOfBar)
    {
    Print(Time[bi].TimeOfDay + " Checking");
    }


    My Output.
    15:28:30 Checking
    15:29:00 Checking
    15:30:30 Checking
    15:31:00 Checking
    15:31:30 Checking


    It seems to maybe happen when ever there is a gap on the chart,
    if looking at the chjart for these two missing times.
    15:29:30 and 15:00:00 it seems they are gapping a bit,

    what causes this and how can i handle this ?

    My end goal is to execute some code as close as posible to the open.
    at the moment i am checking for the end time of the previous candle and if it is first tick of bar.

    is there a better way to do this ?
    Donto
    NinjaTrader Ecosystem Vendor - otrading.dk

    #2
    Hello donto,

    Thank you for your inquiry.

    In 'Time[bi].TimeOfDay', what is 'bi' defined as?

    What instrument (including expiry contract month), bar type, and interval are you testing?

    Are you testing using the Strategy Analyzer?

    If this isn't in the Analyzer, if you right-click within the chart > Reload Historical Data are these bars still missing?

    Are you seeing any errors in the Log tab of the Control Center?

    We also have a reference sample that may be useful to you that demonstrates using IsFirstTickOfBar to separate logic to either calculate once for each bar, or on every tick:



    I look forward to your response.

    Comment


      #3
      Hello Gaby

      bi is defined as 1
      so it should print the close time of the previous bar / open time of current bar.


      I am testing in Market Replay in the above example,

      but i just this instance was running it live to test and i get same results.

      15:28:30 Checking
      15:29:00 Checking
      15:30:30 Checking
      15:31:00 Checking

      I can try doing something in strategy analyzer.

      i do not see any errors or anything in the output or the log.

      Donto
      NinjaTrader Ecosystem Vendor - otrading.dk

      Comment


        #4
        Hello donto,

        Thank you for your response.

        What instrument (including expiry contract month), bar type, and interval are you testing?​

        I would like to test and review the chart on my end.

        Comment


          #5
          Ohh Sorry missed that.
          it is MNQ 03-24
          30 seccond normal standard bars.

          If i open a NQ chart and run through it i get same results there.

          15:25:00 Checking
          15:25:30 Checking
          15:26:00 Checking
          15:26:30 Checking
          15:27:00 Checking
          15:27:30 Checking
          15:28:00 Checking
          15:28:30 Checking
          15:29:00 Checking
          15:30:30 Checking
          15:31:00 Checking
          15:31:30 Checking
          15:32:00 Checking
          15:32:30 Checking
          15:33:00 Checking
          15:33:30 Checking
          15:34:00 Checking
          15:34:30 Checking
          15:35:00 Checking
          15:35:30 Checking
          15:36:00 Checking
          15:36:30 Checking​
          Last edited by donto; 02-08-2024, 08:51 AM.
          Donto
          NinjaTrader Ecosystem Vendor - otrading.dk

          Comment


            #6
            After testing back and forth i tested with another Trading Hours template and found that by changing this it does not happen.
            I offcourse have a template making a break excatley at the open.

            will do some more testing an posible some changes to this and return.
            Last edited by donto; 02-08-2024, 09:05 AM.
            Donto
            NinjaTrader Ecosystem Vendor - otrading.dk

            Comment


              #7
              Hello donto,

              Thank you for letting me know that info.

              If your trading hours template is set to up break / end at the open, this could be why you are are not seeing those bars on the chart. From the Help Guide:

              "When a template is applied, any data outside of the times in the session definitions will be ignored."

              HTML Code:
              https://ninjatrader.com/support/helpGuides/nt8/index.html?using_the_trading_hours_window.htm#UnderstandingTradingHourTemplates
              Since the data is ignored, OnBarUpdate() does not get an update on those bars, so you wouldn't see any prints and IsFirstTickOfBar cannot be true for bars outside of the session definitions.

              Please let me know if you have any further questions.

              Comment


                #8
                try this

                if Calculate = oneachtick
                in OnBarUpdate
                Code:
                if (Time[0].Hour == 9    && Time[0].Minute == 30        && Bars.TickCount < 2 )
                            {
                            }​
                if Calc = on bar close
                Code:
                if (IsFirstTickOfBar    && Time[0].Hour == 9    && Time[0].Minute == 30 )
                            {
                            }​

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                605 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                351 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                560 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                561 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X