Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cumulative index

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

    #16
    Kay, what is the exact issue with the custom code you posted?

    Do you get compile errors, is it crashing or do you not get the values needed returned from it?

    Please use Print() statements throughout the code to debug as needed to make sure calcs are working out as imagined -

    Comment


      #17
      When I include the lines from Value.Set(0); this error pops up - "Error on calling the 'OnBarUpdate' method for indicator"draftpresscum' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

      Comment


        #18
        Expected, as your current bar check does not include those lines to prevent this from happening....try changing it to

        Code:
         
        if (CurrentBar < 2) return;

        Comment


          #19
          Same error message.

          Comment


            #20
            Which exact, complete code are you using Kay?

            Comment


              #21
              "Error on calling the 'OnBarUpdate' method for indicator"draftpresscum' on bar 0: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

              Comment


                #22
                #region Variables
                private DataSeries myDataSeries1;

                protectedoverridevoid Initialize()
                Add(new Plot(Color.Green, "Up"));
                CalculateOnBarClose = true;
                Overlay =
                false;
                PriceTypeSupported =
                true;
                myDataSeries1 = new DataSeries(this);

                #region Properties
                [Browsable(
                false)]
                [XmlIgnore()]
                public DataSeries Upper
                {
                get { return Values[0]; }
                }

                The rest is from the protected override void OnBarUpdate() section that I posted a short while ago.

                Comment


                  #23
                  Kay, please post the full code you use so I can quickly check into and advise, thanks.

                  Comment


                    #24
                    Here it is Bertrand. Forgot I could actually export it!
                    Attached Files

                    Comment


                      #25
                      kaywai,

                      if (CurrentBar > 2 ) return;

                      That is inaccurate. Likely should be < not >.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Josh,

                        1) I changed ">" to "<". The result was a straight horizontal line.
                        2) Next I removed these lines: "Value.Set(0);" and "Upper.Set.myDataSeries1[0]);"
                        3) It kinda gives me what I am looking for. The only thing is it doesn't start from a zero base and I'm not sure what or how it has chosen its base.

                        I've enclosed the amended code and enclosed it.
                        Attached Files

                        Comment


                          #27
                          Kay, great - it would start with the first calculated value after the 2 bars you excluded from the start of the chart, you could for example reset it to 0 at the beginning of a new day / session.

                          Comment


                            #28
                            Bertrand, If it started after the 2nd or 3rd bar, I would understand. In a 15 minute chart, it starts on the 20th bar. On a 30 min chart it also starts on the 20th bar. Do you know why that is the case? I've attached the charts for your attention. You have the code.
                            Attached Files

                            Comment


                              #29
                              This is the unstable period for indicators (20 bars) which are not shown by default, double click on the chart and set 'show unstable period' to true and compare then.

                              Comment


                                #30
                                Much better now.

                                Just one last question on this thread. Is it possible to have the base start as zero as opposed to 1) starting where it is now (no idea how or why it is starting there) or 2) resetting to zero on a daliy basis.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                634 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