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

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
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick answer. worked perfectly.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fitspressoburnfat, Today, 04:25 AM
      0 responses
      2 views
      0 likes
      Last Post fitspressoburnfat  
      Started by Skifree, Today, 03:41 AM
      1 response
      4 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      604 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Working...
      X