Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BAR Lookback

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

    BAR Lookback

    Is it possible to set the bar lookback period in a ninjascript like in the chart data series properties?

    Say for eg: 500 lookback period on 4 range bars


    Thanks

    #2
    Hello,

    Yes you can. My answer assumes that you don't want the indicator to plot before a certain bar. If so, do this:

    if(CurrentBar < myIndyStartBar) return;

    Or if you want to figure it on look back literally, you will need to hold the indicator from plotting until you are getting real-time data, then count back bars and start plotting forward from there. This may help:


    This is just one way to do I that I know of.
    DenNinjaTrader Customer Service

    Comment


      #3
      no i want it too plot, but it requires 500 bars to properly calculate.
      Im assuming you use this figure as if for (return) yeah?

      Comment


        #4
        Hello,

        Yes, do this at the top of the OnBarUpdate block:
        if(CurrentBar < 499) return;
        DenNinjaTrader Customer Service

        Comment


          #5
          thanks ben. will try it.

          Comment


            #6
            Ok well now im not getting any entries when it should.
            Now


            if(CurrentBar < 499)
            return;

            Does this actually indicate for the ninjascript to continue after 500 bars.
            However it doesnt state to the indicator to calculate on the previous 500 bars?

            Comment


              #7
              Hello jthom,

              CurrentBar is a zero-based index for each bar on the chart.

              That line of code tells NinjaTrader to stop all code processing for the first 500 bars.

              Let us know some of the code you're working with and it will be easier to tell if that statement is appropriate here.
              Ryan M.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