Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnBarUpdate

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

    OnBarUpdate

    Hi

    Let's say i place my strategy on a 10 Range chart and there's a 50 points movement on a single tick which cause the creation of 5 new bars.

    When CalculateOnBarClose=false, how many times the OnBarUpdate method will be called? once because it's a single tick or 5 times because of the 5 new bars?

    #2
    Hello kiss987,

    Thank you for your note.

    If CalculateOnBarClose = False, the OnBarUpdate method will be called every time there is a new change in price. NinjaTrader will create synthetic range bars to close gaps in movement such as this.

    If CalculateOnBarClose = True then the OnBarUpdate method would be called 5 times due to the five new bars.
    CameronNinjaTrader Customer Service

    Comment


      #3
      Hi,

      Let's say I have a 1 second chart, and for 5 seconds there was no change of price.

      a) Does the chart creates 5 bars anyway?
      b) If the bars are created, when will they be created - on real time or only after the change of price occur?
      c) Is there a difference if CalculateOnBarClose is set to true or false?

      Thanks

      Comment


        #4
        Hello kiss987,

        a) The chart will create 5 new bars, with an open/high/low/close of that same price. Since NinjaTrader requires volume as part of a bar data, 1 volume will be synthetically created.

        b) Bars will be created in real time.

        c) A new bar is being created and closed every 1 second. So depending on what your strategy or indicator is using for data this can affect how this operates.
        CameronNinjaTrader Customer Service

        Comment


          #5
          Hey guys,

          I have also simple comprehension questions regarding OnBarUpdate, so I thought I will ask it in this thread instead openening a new one. Let's assume following sample strategy:

          Code:
                  protected override void Initialize()
                  {
                      Add(Bollinger(2, 14));
                      Add(Bollinger(2, 14));
          
                      CalculateOnBarClose = true;
                  }
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                      // Condition set 1
                      if (Low[0] <= Bollinger(2, 14).Lower[0])
                      {
                          EnterLong(DefaultQuantity, "");
                      }
          
                      // Condition set 2
                      if (High[0] >= Bollinger(2, 14).Upper[0])
                      {
                          ExitLong("", "");
                      }
                  }
          1. Am I understanding it correct, that if the low is below the lower Bollinger, the long position will be entered on the opening of the next bar? (because Calculateon BarClose=true)

          2. If I would set Calculateon BarClose=false, the long order would immediately be triggered and not wait until the next bar, right?

          3. What would happen, if I use Calculateon BarClose=false + Close [0] instead of Low[0]? Theoretically it should only be triggered if the Close price of the bar is below the Bollinger when the next bar starts, right?

          Thank you very much for helping me to shed light on this topic

          Cheers PaBa

          Comment


            #6
            PaBa, your understanding is correct, however keep in mind CalculateOnBarClose for backtesting / historical data would be 'true' always.

            Also in your last example the Close[0] price would mean the last tick seen, which would not need to be the closing price of the bar.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            649 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X