Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsPeriod typo

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

    BarsPeriod typo

    just wasted some time using a copy/paste from an NT example...see below

    period is missing in BarsPeriod.Value

    might save others some time if corrected

    .....

    Examples

    // Calculate only if there is a 100 tick chart or greater
    protected override void OnBarUpdate()
    {
    if (Bars.Period.Id == PeriodType.Tick && BarsPeriod.Value >= 100)
    {
    // Indicator calculation logic here
    }

    #2
    Thank you for reporting ATI user.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      now I really am confused...

      The typo I reported is in Help under 'Period'...it uses both Bars.Period and BarsPeriod in the same line of code. It also recommends using BarsPeriod for strategies

      I notice that you can not use Bars.Period in the Initialize method of an NT strategy....however BarsPeriod works fine. In the OnBarUpdate method of a strategy you can use either (and I am).

      In an NT indicator you can only use BarsPeriod. This is how I found the typo...i.e. I had copied code from my strategy into my indicator and it did not compile...looked up syntax in Help and found typo.

      1. Please explain the difference and why NT has both options. It seems to promote confusion/errors.

      2. Should I change all instances of Bars.Period in my strategy to BarsPeriod? Why?...as in why allow both in strategies if BarsPeriod is recommended/better for strategies

      Comment


        #4
        1. Use Bars.Period in an indicator. Use BarsPeriod in a strategy.

        2. BarsPeriod is for the primary series. Please follow the suggestion and use BarsPeriod.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          2. BarsPeriod is for the primary series. Please follow the suggestion and use BarsPeriod.
          use BarsPeriod in the strategy for all series I assume you mean

          Comment


            #6
            ATI user,

            No. BarsPeriod returns the primary series. Please use BarsPeriod when using a strategy. If you need the others series then use Bars.Period when appropriate.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

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