Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FirstTickOfBar executed twice

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

    FirstTickOfBar executed twice

    While debugging a problem, I've come accross something that does not look right. The indictor runs with CalculateOnBarClose = false, and uses FirstTickOfBar to perform some tracking that must only be done once per bar.
    The chart is setup before a session start time (not yet updating with realtime data), then on the first bar of the new session the code that runs within FirstTickOfBar is executed twice on that bar. This can cause my tracking variables to hold incorrect values. If the indicator is reapplied during the session, then it will only perform FirstTickOfBar once on that first bar. I have used Tick and Range chart types, Ninja version is 6.5.1000.8
    I beleive I now have a work-around, but is this a bug or expected behavoir?

    #2
    Hi MJT, thanks for the post - do you have sample code to post so I can reproduce and check it on my end?

    Comment


      #3
      Yes Bertrand,
      This should only print to the output window if FirstTickOfBar occurs more than once on the same bar. Set chart session start time to later than current time. Apply indicator, and wait for the session to start.
      Attached Files

      Comment


        #4
        Hi MJT, thanks for bringing this to our attention, I could reproduce this on 6.5

        Comment


          #5
          Thank you Bertrand. I am surprised this has not been identified before, and have been trying to identify the odd behavoir for a long time assuming it was due to an error in my programming.
          Is there a suggested work-around for this?

          Comment


            #6
            Hi MJT, since you already know how to detect this, you can simply ignore it with return out...

            Comment


              #7
              I have now found several other cases in my indicator and in others where this bug causes errors, although most have gone unnoticed in the past. I have now made my own method (using that same bar counting logic), and replaced all instances of FirstTickOfBar.
              That is a more reliable and acutally easier to manage work-around.

              Comment


                #8
                Hi MJT, sorry for the inconvenience caused and great you found a workable solution.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                574 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                332 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                553 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X