Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Maximum Bars Lookback

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

    Maximum Bars Lookback

    I am using a Plot override to draw graphics. The logic works fine in NT 6.5 and works in NT 7 back 256 bars after which the indexing seems to get lost and values retrieved from OBU are incorrect. The value are correct in OBU and plot correctly from there.

    I have set the Max bars lookback parameter to infinite but the issue doesnt change.

    This could be a scripting error on my part. However, it seesm strange that the problem occurs after 256 bars - perhaps there is an issue with Maximum bars lookback within graphics?

    Also - is there on overide setting for Max bars that can be included in Initialize?

    Thanks

    #2
    Can you strip down your indicator and provide a simple as possible (!) sample which demonstrates your observation? Thanks

    Comment


      #3
      Dierk,

      I emailed the indicator and a screen shot to you @ support a couple of hours back.

      Let me know if you need more info...

      Comment


        #4
        Would you mind sending it right to me again (in case you're online). "dierk AT ninjatrader DOT com". Our support team might be offline for a couple of more hours.

        Comment


          #5
          Also having this problem

          I have 2136 bars on my chart and the indicator looks for identical numbers in a DataSeries, referencing each bar back using a for loop. Even though I set the indicator to infinate, it still gives the error about 256 bars . Quick fix here?
          lawyse
          NinjaTrader Ecosystem Vendor - Affordable Indicators

          Comment


            #6
            Not sure what you mean by "quick fix". I suggest inspecting your code if you're using custom data series and setting them to "infinite" as well.

            Comment


              #7
              How would I set a DataSeries to infinate? I don't see anything about this in the help file DataSeries Class page. Thanks!
              lawyse
              NinjaTrader Ecosystem Vendor - Affordable Indicators

              Comment


                #8
                Please try e.g.
                Code:
                new DataSeries(this, MaximumBarsLookBack.Infinite);
                Thanks

                Comment


                  #9
                  Out of Index Exception caused by MaximumBarsLookback.Infinite

                  Have coded an indicator that uses several DateTimeSeries[] arrays (6x6). It works fine on NT 6.5. but shows a strange behavior on NT 7.0.0.12 The DateTimeSeries[] objects are used to assign a Date to each bar which is printed via a customized plot.

                  (1) Observed as expected: If Maximum bars look back is set to "Twohundredfiftysix", the DateTimeSeries[] only stores correct values for the last 256 bars. If I go further back, false dates are displayed.

                  (2a) Observed as expected: If I set Maximum bars look back to infinite, I can horizontally scroll the chart back and the dates displayed are correct.
                  (2b) Alternatively I can set DataSeries(this, MaximumBarsLookBack.Infinite) via indicator code.

                  Everything works fine (adding indicator or refreshing via F5), if I add the indicator, when the chart is right-aligned to the last bar - as per default when the chart is opened.

                  Not expected

                  However, if I add the indicator, after having horizontally scrolled back the chart a few days, I get a plot error with an out-of-index exception. This exception is not triggered with NT 6.5, and it is not triggered with NT7, as long as Maximum bars lookback is not set to "Inifnite". So it must be caused by the custom plot accessing the DateTimeSeries, while not pointing to one of the last bars.

                  What I do not understand so far....

                  -> Indicator can be added, when chart is in default position -> once added you can scroll back to the beginning of the chart and everything is ok.

                  -> Indicator can not be added in MaximumBarsLookback.Infinite mode, if chart is scrolled back a few days. Out-of-index exception is triggered.

                  Thanks for your help.

                  Comment


                    #10
                    Hi Harry, would you have a stripped down version exhibiting the 'not expected' issues you raised so I can check into and reproduce here?

                    Thanks in advance

                    Comment


                      #11
                      Hi Bertrand,

                      thanks for your answer. I do not have a stripped down version of the indicator. More over I think that a stripped down version would not expose this behavior. I think that NT 7 limits the use of memory in a different way that NT 6.5 did. The same code works for NT 6.5

                      Below an indicator Test, which

                      -> ok in 256 bars mode
                      -> ok in infinite mode, if put on, when chart right-aligned
                      -> not working (out-of-index exception), if put on when chart in middle position

                      To check just open a 65 day, 30-minute chart, add indicator; set right chart margin to 100 under chart properties and set Maximum bars look back to "Infinite". Then scroll horizontally and refresh via F5. You will find that the indicator can be added or will cause an exception depending on the position of the scroll bar. Once added it will work to the left of the place where it was added, but not to the right.

                      Any ideas?
                      Attached Files

                      Comment


                        #12
                        Thanks for your efforts Harry, got it to reproduce here - we're checking into.

                        Comment


                          #13
                          Harry,

                          The message indicates you most likely ran into some issue with the way you are programming in the Plot method. This is an unsupported method. Unfortunately we are not able to debug the 5000 lines of code in the indicator. I suggest you strip it down to a single plot which you can reproduce the issue with. Maybe try using some try-catch blocks around to see which line breaks the logic. Error message means that you are accessing an index that simply does not exist in your code in the scenario you have described.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you Josh for the answer,

                            I am sorry that I could not simplify the indicator to produce the error, there are some hints that it must be memory related....

                            (1) The out-of-index error only occurs, when I set the DateTimeSeries[] array to MaximumBarsLookBack. Infinite.
                            (2) In the region OnBarUpdate() the indicator writes DateTime values to the DateTimeSeries[] arrays.
                            (3) Plot retrieves these values and prints them.

                            The code works on NT 6.5. but causes an out-of-index error on NT 7. This error only occurs with MaximumBarsLookBack.Infinite. The error occurs more likely, if I use a smaller period (1 min) than if I use a larger period.

                            So the problem is likely not caused by the code but by MaximumBarsLookBack.Infinite. If I write a new code with a single DateTimeSeries, I might not activate the bug. I will think about writing an indicator that isolates the problem.

                            Comment


                              #15
                              Hi Harry, thanks for clarifying and adding those remarks, appreciated.

                              Do you see the same result if setting the lookback for the DateTimeSeries programmatically to be infinite?

                              Comment

                              Latest Posts

                              Collapse

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