Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Linnear Regression Intercept crashes

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

    Linnear Regression Intercept crashes

    When I add condition 1 to draw vertical lines when price closes below the indicator and had not closed below it 1 bar ago (and the reverse for condition 2) the indicator compiles but crashes when loading.
    I got the code from strategy builder then copied the new added lines to the ninja 7 default Linnear Regression Intercept which i then renamed in order to save with the changes.

    // Condition set 1
    if (LinRegInterceptClosingColorchange(14)[0] > Close[0]
    && LinRegInterceptClosingColorchange(
    14)[1] <= Close[1])
    {
    //BackColor = Color.White;
    DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Lime);
    }

    // Condition set 2
    if (LinRegInterceptClosingColorchange(14)[0] < Close[0]
    && LinRegInterceptClosingColorchange(
    14)[1] >= Close[1])
    {
    //BackColor = Color.Yellow;
    DrawVerticalLine("My vertical line" + CurrentBar, 0, Color.Red);
    }

    #2
    simpletrades, what do you exactly mean by 'crashing'? Did you notice any errors in the log tab then?

    Thanks,

    Comment


      #3
      "NinjaTrader application has encountered a problem and needs to close" pops up about a minute or so after i load the indicator, hit apply and watch a black chart window longer than usual for loading an indicator.

      Comment


        #4
        the log says something like error on calling onbar update method on bar 0. You are accessing an index with a value that is invalid since it is out of range.

        Comment


          #5
          Do you run a CurrentBar check then at the top of your OnBarUpdate() start?

          Comment


            #6
            which one should i use? i found these in other codes.
            if (CurrentBar == 0);
            or
            if (CurrentBar < lookback) return;

            is the second one very memory intensive?

            edit: the first one still crashed.
            second one didnt recgnize the term 'lookback' so i used 250 instead since the indicator window said max bars were two hundred fifty-six and it still crashed.

            Last edited by simpletrades; 07-04-2011, 10:52 AM.

            Comment


              #7
              You would need to use the second one with a lookback value min 1, as you would not want the code to do any OnBarUpdate() call for CurrentBar == 0.

              Comment


                #8
                i tried this and it still crashed too

                if (CurrentBar < 1) return;

                next i'll try
                if (CurrentBar > 1) return;

                nope.
                Last edited by simpletrades; 07-04-2011, 10:59 AM.

                Comment


                  #9
                  The second variant will not help you here - could you please attach the script you use or email me directly at support at ninjatrader dot com?

                  Thanks,

                  Comment


                    #10
                    its the default script included in ninja 7.0 for Linnear Regression Intercept.

                    all i added was the condition 1 and 2 i reproduced above.
                    nothing anywhere else except for your idea.

                    the script works without conditions as just the regression line but crashes ninja if i add conditions.

                    Comment


                      #11
                      The color Change method you use is definitely a custom script, if I have no access to it, I could not reproduce the issue here for you.

                      Comment


                        #12
                        the colorchange part in the name was what i had to rename the original one you supply in order to save the condition 1 and 2 which was the only difference besides the color of the regression line it draws

                        both versions are attached.
                        i tried backcolor first then vertical lines.
                        Attached Files
                        Last edited by simpletrades; 07-04-2011, 11:14 AM.

                        Comment


                          #13
                          You could not self reference a script, please give the attached a try, it simply calls the method you need for your conditions and then draws the lines as needed.
                          Attached Files

                          Comment


                            #14
                            nope.
                            i saved it to my desktop, copied it into my ninja 7 indicator folder, opened the indicator thru tools, compiled it and when i loaded it, ninja still crashed.

                            Comment


                              #15
                              Please recheck all steps very carefully, and remove your other script completely before any other step.

                              Then simply import the zip I attached for you now, works perfectly here.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              577 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              334 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X