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

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?
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        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...
            BertrandNinjaTrader Customer Service

            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.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DJ888, 04-16-2024, 06:09 PM
                4 responses
                12 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by terofs, Today, 04:18 PM
                0 responses
                7 views
                0 likes
                Last Post terofs
                by terofs
                 
                Started by nandhumca, Today, 03:41 PM
                0 responses
                6 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
                9 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Working...
                X