Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CurrentBar[0]

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

    CurrentBar[0]

    Hi,

    If I running on Historical Data and primary bar index is 10 min and secondary bar index is 1 Tick, if I Call Closes[0][0] in OnBarUpdate for the 1 tick seires will I get the Close of the last 10min bar OR the price of the current 10min bar that is forming? ie

    Code:
    If(BarsInProgress == 1)
    {
         // is x the close of the last 10 min bar or the price of the one forming now?
         double x = Closes[0][0] ;
    
    }

    #2
    Hello,

    When processing historical data, you should see the final close price of the current bar of the primary 10-minute series (the bar on the primary series that would have been forming at that time). For example, when this code runs on a tick that comes in at 3:34pm, you will receive the final close price of the 3:40pm bar for the 10-minute series.

    Since the primary bar will already have its final close price, even at a time when that bar would not have been closed in real-time, Closes[0][0] will refer to that price.

    Once the script switches to realtime, you would then receive the final close price of the previous primary bar.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Originally posted by GKonheiser View Post
      Hi,

      If I running on Historical Data and primary bar index is 10 min and secondary bar index is 1 Tick, if I Call Closes[0][0] in OnBarUpdate for the 1 tick seires will I get the Close of the last 10min bar OR the price of the current 10min bar that is forming? ie

      Code:
      If(BarsInProgress == 1)
      {
           // is x the close of the last 10 min bar or the price of the one forming now?
           double x = Closes[0][0] ;
      
      }
      'x' is always the close of the last 10 min bar

      Why?
      Because the close price of the bar that is forming now has not finished yet, so no 'Close' price is available.

      I'm not sure what historical vs realtime has to do with it. Dave, could you elaborate again on this distinction?

      Comment


        #4
        That's a good question, and I actually should have mentioned that what I noted would apply with CalculateOnBarClose = False. In this case, referencing Close[0] in realtime will give you the Last price of the currently forming bar as it forms. On Historical data, we don't have the same concept of a "currently forming bar," because we are actually working with 4 already-defined data points for each historical bar (Open, High, Low, Close). So if you reference the close price of a historical bar, at a time when the bar would not yet have closed if it were realtime, the final close price does already exist in the OHLC values, so Close[0] will refer to the actual closing price of that bar.

        With CalculateOnBarClose = True, then the same concept applies, but with a different discernible result. What you will see in this case, is that Close[0] will still represent the Last traded price, but it will happen on the last tick of the bar (a.k.a. the Close). Thus, the instant that the script processes this, a new bar will begin forming, which gives the impression that Close[0] referenced the previous bar.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Because when running live data Close[0] == Current Last Price if CalculateOnBarClose == False.

          Comment

          Latest Posts

          Collapse

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