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

Easiest way to check for last tick on a tick bar?

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

    Easiest way to check for last tick on a tick bar?

    There are some calculations that I want to update with every tick. I also want to do some additional processing on the last tick of a bar. How can I determine the last tick on a bar? Thanks.

    Actually, how can I detect the end of a bar whether it be a "tick bar" or a time based bar? Thanks.
    Last edited by higler; 05-10-2007, 04:12 PM.

    #2
    For time based intervals, there is no way to know if a tick is the last tick of a bar. The reason is, you don't know a tick was the last tick until you know you have the first tick of the bar and at that time, the last tick of the prior bar has already been processed.

    For a tick bar, try checking the TickCount property.
    RayNinjaTrader Customer Service

    Comment


      #3
      On a tick chart I just experimented with checking Bars.TickCount and have an interesting situation. I modified my indicator to to check for the last tick. I applied it to a 150 tick bar chart and I have my indicator reporting Bar.TickCount to the Data Box. All my historical bars list the TickCount at 138.0. All my bars accumulated real time list the "correct" 150.0 TickCount after the close of the bar. As a result, my indicator doesn't perform the end of bar calculations on the historical bars but does perform them on the "real time" bars. Am I missing something on getting the historical bars to report the "correct" end of bar tick count? I would like my indicator to calculate both the historical and real time bars. Thanks.

      Comment


        #4
        Is this reproducible on any tick based interval? Meaning, the histrical tick count is different than real-time?

        If yes, would you mind sending me the indicator and we will research this further.

        ray at ninjatrader dot com
        RayNinjaTrader Customer Service

        Comment


          #5
          I'll experiment with it and get back with you. Thanks.

          Comment


            #6
            After looking more closely at the code and documentation, it appears that the error was on my part, naturally. In the documentation is looks like Bars.TickCount refers to the number of ticks of the CURRENT bar, so for older (historical) bars in the Data Box it was just showing what the TickCount was when I "started up" the indicator. So, if I also do a check for Historical then I can get the calculations that I want on either Historical or Real Time bars.
            I couldn't find any documentation on Bars objects which would probably help me. Thanks.

            Comment


              #7
              Right, thanks for figuring this out. There is no documentation on the Bars object since only specific properties of that object are exposed and supported in the NinjaScript layer. Those that are supported are documented.
              RayNinjaTrader Customer Service

              Comment


                #8
                TickCount for historical data?

                Originally posted by higler View Post
                After looking more closely at the code and documentation, it appears that the error was on my part, naturally. In the documentation is looks like Bars.TickCount refers to the number of ticks of the CURRENT bar, so for older (historical) bars in the Data Box it was just showing what the TickCount was when I "started up" the indicator. So, if I also do a check for Historical then I can get the calculations that I want on either Historical or Real Time bars.
                I couldn't find any documentation on Bars objects which would probably help me. Thanks.
                I have a strategy which sets CalculateOnBarClose = false such that OnBarUpdate gets called for each tick. As described in the quote, I also get Bars.TickCount as a never changing value while processing historical data for backtesting. How do I reference TickCount within historical bars ?

                Comment


                  #9
                  On historical bars, CalculateOnBarClose always functions as if it is set to true. This is because historical bars are only bars and not tick by tick.
                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottWalsh, Today, 06:52 PM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by trilliantrader, Today, 03:01 PM
                  2 responses
                  19 views
                  0 likes
                  Last Post helpwanted  
                  Started by cre8able, Today, 07:24 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post cre8able  
                  Started by Haiasi, Today, 06:53 PM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by ScottW, Today, 06:09 PM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X