Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CalculateOnBarClose clarification

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

    CalculateOnBarClose clarification

    Hi there,

    If I have CalculateOnBarClose = false i.e. I am running OnBarUpdate each tick, what happens in code where you have references to the bar close/high/low values when the bar hasn't closed yet? Is the close/high/low on the partial bar given or that of the preceding bar?

    The reason I am asking is that I have a need to run one method on a bar close and another method that needs to be updated on each tick. Having CalculateOnBarClose = false is inefficient in the first instance. I saw your reference to using FirstTickOfBar to separate out the two although (and I know I am nit-picking in any liquid market) this is not ideal since you have a delay between the closing bar and the first tick of the next bar which (theoretically) might not happen for a while.

    Thanks for the help

    regards

    #2
    CalculateOnBarClose set to false will give you the current bar's Close/High/Low values. Doing Close[0] will give you the latest tick's price. High[0] will give you the current High price based on the ticks that have already passed.

    The only way NinjaTrader knows a bar has closed is by the incoming timestamp of the first tick of the next bar. Let's say you have a 1min bar at 9:00AM. NinjaTrader needs to see a timestamp of at least 9:01:00 before it knows that the 9am 1min bar has closed.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the info. Useful to know.

      regards

      Comment


        #4
        I want to do intra bar calculations on some variables, and end of bar calculations on others.

        Is it possible to know the closing tick of a bar? If not, can I just use the FirstTickOfBar() function and use the Close[1] to do calculations as if it was the Close of the bar?

        I'm using range bars.

        Thanks
        Anthony
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Originally posted by mrlogik View Post
          If not, can I just use the FirstTickOfBar() function and use the Close[1] to do calculations as if it was the Close of the bar?

          Thanks
          Anthony
          This is the right approach.
          RayNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          44 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          20 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          179 views
          0 likes
          Last Post jeronymite  
          Started by ghoul, Today, 06:02 PM
          0 responses
          9 views
          0 likes
          Last Post ghoul
          by ghoul
           
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Working...
          X