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

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 cre8able, Today, 01:01 PM
              0 responses
              2 views
              0 likes
              Last Post cre8able  
              Started by manitshah915, Today, 12:59 PM
              0 responses
              2 views
              0 likes
              Last Post manitshah915  
              Started by ursavent, Today, 12:54 PM
              0 responses
              3 views
              0 likes
              Last Post ursavent  
              Started by Mizzouman1, Today, 07:35 AM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by RubenCazorla, Today, 09:07 AM
              2 responses
              13 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X