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

Accumulating statistics using Calculate.OnEachTick

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

    Accumulating statistics using Calculate.OnEachTick

    Hi Ninjatrader experts,
    I have a question when accumulating data using OnEachTick.
    How do you monitor the ticks so that you can update the statistic for a bar on the last tick of the bar? I am aware of IsFirstTickOfBar but is there a particular code design pattern or some kind of Api that can be used to do this?
    Is there a sample template one can follow?
    Thanks,
    iq

    #2
    Hello iq200,

    Thanks for your post.

    Unfortunately, NinjaTrader has no methods or documentation for detecting the Last tick of a bar.

    That said, see this forum thread which you may find helpful: https://ninjatrader.com/support/foru...050#post793050

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      HI Brandon,
      Thank-you for your reply.

      Sorry, I forgot to mention my case in detail. The example you gave is not relevant.

      I am actually using minute bars as my primary data stream and using tick data for my secondary data stream. I am accumulating statistics in my secondary stream to use in my indicators which bind to the primary data stream. That said, I am sure this case is quite common although perhaps a little advanced for the everyday user. This is why I was asking here.

      Regards,
      iq

      Comment


        #4
        Hello iq200,

        Thanks for your note.

        As previously stated, NinjaTrader has no methods, documentation, or sample code for detecting the last tick of a bar.

        This thread will be open for other community members on the forums to share their insight on undocumented means for detecting the last tick of a bar.

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I'm not necessarily looking for a way to detect the last tick but to HANDLE the last tick and complete the statistic for the bar.

          Comment


            #6
            Hello iq200,

            Thanks for your note.

            If you are using tick-based bars, like a 150 tick bar, you could consider counting the ticks and call an action on the 150th tick, then reset the counter every time you see IsFirstTickOfBar.

            Note that this would not work for Renko bars.

            Or, you could consider using similar logic to the BuySellPressure indicator that comes default with NinjaTrader. The BuySellPressure indicator logic sets the value of the last bar on the first tick of a new bar. See the BuySellPressure indicator code in a NinjaScript Editor window.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hi Brandon.
              Yes! The last idea sounds like the best practical idea so far. I'll try it out.
              Many thanks.
              Regards,
              iq

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,606 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              8 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              18 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              4 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              13 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X