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

Accumulate and calculate on each tick.

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

    Accumulate and calculate on each tick.

    I am developing an indicator that I want to accumulate data, calculate values, and sums the values on each tick in a bar over the course of the bar. At the end of the bar I want to plot a value based on the cumulative calculations and sums. I have some questions:

    1. Is the OnBarUpdate() method called on each incoming tick? What are the effects of "calculate on bar close" being set to true vs. false?

    2. How does the OnBarUpdate() method handle historical data? (I am using Zenfire). Would OnBarUpdate() calculate on individual ticks for historical data or would this only work for real time data?

    3. What is the first tick of a bar in the TickCount property? 0 or 1?

    4. What is the easiest way to detect the last tick of a bar?

    Thanks.

    #2
    1. The answer is yes when this property is set to false.
    2. On historical data, OnBarUpdate() can only be called once per bar but in real-time it will be called on each tick if #1 above is false.
    3. 1
    4. There is no way to do this since in time based bars you don't know the last tick until you have the first tick of a new bar. For tick based bars, you can just count the ticks yourself.
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray

      Thank you. I can't believe how fast you guys respond. So, if I am using tick based bars and want to detect the last tick of the bar then I can check BarsPeriod.Id to ensure PeriodType.Tick and then check to see if Bars.TickCount == BarsPeriod.Value

      Thanks.

      Comment


        #4
        Yes, I believe that would work.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X