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

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.
      BertrandNinjaTrader Customer Service

      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.
          BertrandNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by frslvr, 04-11-2024, 07:26 AM
          8 responses
          111 views
          1 like
          Last Post NinjaTrader_BrandonH  
          Started by stafe, 04-15-2024, 08:34 PM
          10 responses
          43 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by rocketman7, Today, 09:41 AM
          3 responses
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by traderqz, Today, 09:44 AM
          2 responses
          5 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by rocketman7, Today, 02:12 AM
          7 responses
          31 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X