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

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,
    BertrandNinjaTrader Customer Service

    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?
          BertrandNinjaTrader Customer Service

          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.
              BertrandNinjaTrader Customer Service

              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,
                  BertrandNinjaTrader Customer Service

                  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.
                      BertrandNinjaTrader Customer Service

                      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
                          BertrandNinjaTrader Customer Service

                          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
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by usazencort, Today, 01:16 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post usazencort  
                              Started by kaywai, 09-01-2023, 08:44 PM
                              5 responses
                              603 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              6 responses
                              22 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Pattontje, Yesterday, 02:10 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post Pattontje  
                              Started by flybuzz, 04-21-2024, 04:07 PM
                              17 responses
                              230 views
                              0 likes
                              Last Post TradingLoss  
                              Working...
                              X