• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator OnBarUpdate on each new tick

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

    Indicator OnBarUpdate on each new tick

    I was wondering whether someone could help me with a question regarding NT indicators when used on a chart and "Calculate on bar close" equals FALSE.

    If the Indicator OnBarUpdate is called on each new tick the series will grow to hold 1 indicator value for each tick, in addition the indicator won't have the correct values. An SMA on 20 1 minute bars calculated each new ticks will be an SMA on 20 ticks. (At least that's how the code looks like).

    Does NT drop the last value in the series until the bar is fully calculated ?

    What happens to local variables in the script, do you use reflection to rollback their values to before the previous tick update ?

    #2
    Welcome to our forums - only the last bar would be affected here, so the your SMA would be working over the last 19 (closed bars) and then updating calcs based on the last tick seen. It would still be a 20 bar SMA at all times, no matter how many live tick updates your OnBarUpdate() would have been called for. Once the currently developing bar is completely build the process would shift one bar forward of course.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply! I'm still missing one piece here, what happens to the local script variables that the indicator is using ?

      Many indicators use variables for various calculations if those are updated tick by tick by the OnBarUpdate function then the indicator value won't come out right since they should be holding the values set by the last full bar and not the previous tick.

      So the question is are those variables rolled back on each tick to the value that existed at the previous bar end ?

      For example: The Aroon indicator has these local variables in it:
      " private double runningMax;
      private int runningMaxBar;
      private double runningMin;
      private int runningMinBar;"

      Those are updated on each tick but this would result in an incorrect calculation if they are not rolled back to their previous values after each tick.

      Comment


        #4
        Sorry I don't follow you - the same applies to the variables as well, your full OnBarUpdate() is rerun for each tick and thus the updated results are used. If we get a bar closure on the first tick of new bar > they will update as well using closing tick for the bar.

        You can access that state running COBC = false and save anything to a custom tracking variable if desired that you would have access to intrabar as the bar updates.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          So NT assumes that the designer of the Indicator uses local variables in such a way that is compatible with both ticks updates and bar updates ?

          Local variables that are used with the assumptions of bar updates might do various calculations which might not be valid if the indicator is updated tick by tick.

          My question was basically whether NT magically (using reflection or new objects) restores these local variables to their values at the last full bar. Thus allowing the designer of the indicator to ignore the possibility that the indicator might be updated on each new tick.

          Comment


            #6
            You're correct in understand Alon, the developer would need to be aware and handle if code is sensitive to that. The variable would hold whatever value you last set it to via code, there would be no 'under the hood' handling by NT.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thank you! I'm not sure that all of your indicators are aware to that. Looking at the code some might result in a different values processing tick updates and bar updates - but I could be wrong. Thanks, you answered my questions.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Venom, Today, 01:05 PM
              0 responses
              1 view
              0 likes
              Last Post Venom
              by Venom
               
              Started by Dert66, Today, 12:11 PM
              0 responses
              5 views
              0 likes
              Last Post Dert66
              by Dert66
               
              Started by jjanguda, Today, 10:04 AM
              0 responses
              187 views
              0 likes
              Last Post jjanguda  
              Started by sambo81, Today, 09:20 AM
              1 response
              12 views
              0 likes
              Last Post sambo81
              by sambo81
               
              Started by TopGunNote, 05-14-2019, 01:12 PM
              3 responses
              78 views
              0 likes
              Last Post dpaulw
              by dpaulw
               
              Working...
              X