Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

what "bar" am I on?

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

    what "bar" am I on?

    how do I tell which "bar" I'm on, since "the beginning of time"... (Not referring to the "barsobject") (referring to the last bar on the right on the chart). I want to use that "bar" magnitude in my indicator. If there isn't any such thing, then, is there a way to detect when I've moved from the previous "bar" to the present (last on the right) bar? I'm not sure the "FirstTickOfBar" variable is always valid... an entire 5-minute bar could elapse with no tick in a thinly-traded market.

    #2
    Hello jalexan1,

    Thanks for your post and welcome to the forums!

    The bars are number from the beginning of the days back requested (or bars back) and will start at the first bar loaded, bar 0, progressing to the bar on the right end of the chart, incrementing the bar count. The integer CurrentBar will hold the bar number. reference: http://ninjatrader.com/support/helpG...currentbar.htm

    When working with price data, such as High or Close you would provide a reference to the bar to use. To make things easy the concept is to use a "bars ago" reference. For example Close[0] refers to the current bar, Close[1] refers to the previous bar, Close[2] to the bar before that, etc. Reference:http://ninjatrader.com/support/helpG...rice_data2.htm

    Note that the bars ago reference does change depending on the setting of CalculateOnBarClose. If set to true, [0] will point to the last completed bar on the right edge but not the current forming bar. If set to false, then [0] will point to the currently forming bar. Reference: http://ninjatrader.com/support/helpG...onbarclose.htm

    With CalculateOnBarClose set to true, your code would execute once at the end of the bar.

    With CalculateOnBarClose set to false, your code would execute on every incoming tick and in this mode FirstTickOfBar will be true on the very first tick of the newly forming bar. You are correct that in a thinly traded market it may take a while to get that first tick but it will still trigger FirstTickOfBar. Reference: http://ninjatrader.com/support/helpG...ttickofbar.htm

    Comment


      #3
      Thanks for the quick answer. worked perfectly.

      Comment

      Latest Posts

      Collapse

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