Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bars.Count and CurrentBar Question

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

    Bars.Count and CurrentBar Question

    I'm working with historical data only and noticed the following values on the last OnBarUpdate() call:

    Bars.Count: 1782
    CurrentBar: 1780

    I painted the CurrentBar and noticed it was the second from the last closed bar, not the last as I expected it to be.

    So my question is first why isn'tt OnBarUpdate fired on bar 1781 (the real last bar) and why bar 1780 the last bar?

    And why isn't Bars.Count not equal to CurrentBar on the last bar?

    NT7Beta18 if it matters....

    #2
    Originally posted by miker View Post
    I'm working with historical data only and noticed the following values on the last OnBarUpdate() call:

    Bars.Count: 1782
    CurrentBar: 1780

    I painted the CurrentBar and noticed it was the second from the last closed bar, not the last as I expected it to be.

    So my question is first why isn'tt OnBarUpdate fired on bar 1781 (the real last bar) and why bar 1780 the last bar?

    And why isn't Bars.Count not equal to CurrentBar on the last bar?

    NT7Beta18 if it matters....
    Hi miker,

    CurrentBar is zero based index, so if Bars.Count is 1782, the "very last CurrentBar" will be 1781.

    If CalculateOnBarClose is set to "true", then CurrentBar is 1780 since very last bar on the chart is not closed until new bar is opened.
    ArtSenior Software Developer

    Comment


      #4
      miker, this is expected in NT as charts are build event based, not time based - the bar is opend if a new tick is received.

      Comment


        #5
        i get that it's event based....so if bar 1781 CLOSES and CalculateOnBarClose is TRUE, then there's your event...so again, why wait until the next bar opens?

        Comment


          #6
          miker, because the old bar does not close until you receive the opening tick of the new bar.

          Comment

          Latest Posts

          Collapse

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