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

Calculate On Bar Close/Open-Low-High-Close relationship

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

    Calculate On Bar Close/Open-Low-High-Close relationship

    Hi all,

    If 'Calculate on bar close' if False are the values of Open[0], Close[0], High[0] and Low[0] modified with each tick before OnBarUpdate gets called?

    I'm guessing the answer is yes but want to confirm.

    john

    #2
    Hi John,

    Thanks for the post. The standard Open ,High, Low, Close values for your bars would be considered price data, so they will update independent of CalculateOnBarClose settings. There isn't available a COBC setting for standard price bars.

    If you use Open[0], Close[0], etc in a script, then their values will update according to the scripts' CalculateOnBarClose settings. If CalculateOnBarClose = false, then OnBarUpate() will be raised with each tick. If COBC = true, then OnBarUpdate() is raised only on bar close.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response. I didn't ask the question well. I understand that onbarupdate is called differently based on the CalculateOnBarClose setting.

      The scenario I was exploring was if CalculateOnBarClose is false and OnBarUpdate is called with each tick. In that scenario are High[0] and Low[0] updated by the platform with each tick or is High[0] only set at the end of the time frame? I want to be absolutely sure.

      john

      Comment


        #4
        Hi John, they would be updated with each tick as well, so as new Highs and Lows are seen. With CalculateOnBarClose set to 'false' index 0 always means the currently developing / updating bar. With CalculateOnBarClose set to 'true' index 0 means the last completed bar.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          On historical testing I understand the setting 'calculate on bar close' = false is irrelevant as it is always calculated as 'calculate on bar close' = true.

          I have a strategy that enters a limit order 3 pips lower than the high of the last bar. What I would like the strategy to do is that:

          "IF two bars have passed since the limit order was placed and the limit order is not filled, cancel the limit order". I have done this for historical testing by assigning an integer variable (called 'barcount') thats adds 1 to itself each time OnBarUpdate is called, and when 'barcount' = 3 then do not resubmit the limit order. This works on historical testing because OnBarUpdate is called on each bar for historical testing ('calculate on bar close' = true).

          So...my question is how do I achieve the same thing for live testing when 'Calculate on bar close' = false, as each OnBarUpdate will calculate on each tick.?

          Many thanks.

          Comment


            #6
            Hi adam_norsworthy,
            You can check when property FirstTickOfBar == true which is only once per bar. A sample showing best way to combine bar close/every tick logic is available here:
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Perfect. Thanks Ryan.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by chartchart, 05-19-2021, 04:14 PM
              3 responses
              577 views
              1 like
              Last Post NinjaTrader_Gaby  
              Started by bsbisme, Yesterday, 02:08 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by prdecast, Today, 06:07 AM
              0 responses
              3 views
              0 likes
              Last Post prdecast  
              Started by i019945nj, 12-14-2023, 06:41 AM
              3 responses
              60 views
              0 likes
              Last Post i019945nj  
              Started by TraderBCL, Today, 04:38 AM
              2 responses
              18 views
              0 likes
              Last Post TraderBCL  
              Working...
              X