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

Creating a Regression Channel

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

    Creating a Regression Channel

    Hello,

    I am working on creating a regression channel using the DrawRegressionChannel() function built into NT.

    Is it possible using this function to set some sort of Regression Factor to change the width of the channel?

    Thanks.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    #2
    DrawRegressionChannel() does not return any values you can use. RegressionChannel() is the indicator you should call to get values for the channel.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply Josh. I'll look into that.
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Hey Josh.

        Using DrawRegressionChannel() does not input a width for the number of stand devs, yet RegressionChannel() does not have this input. My code is as such.

        Code:
        DrawRegressionChannel(    CurrentBar.ToString(), false, 0, bSinceLineUp, 
                                                    Color.White, DashStyle.Solid, 1, 
                                                    Color.White, DashStyle.Dash, 1, 
                                                    Color.White, DashStyle.Solid, 1);
        Where bSinceLineUp is the number of bars used for the calculation.

        How can I get the Upper / Lower channel values using RegressionChannel() indicator call if to .Upper / .Lower if RegressionChannel() uses requires a width input, but the DrawRegressionChannel() does not. Does DrawRegressionChannel() have a default value of width of 1?

        Thanks for your help.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Hi,

          Not sure I follow. The Regression Channel indicator does have a width input.
          Code:
          RegressionChannel(int period, int width)[int barsAgo]
          I guess I'm not sure what you are asking.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Hey Josh.

            I'm plotting right now using the DrawRegressionChannel() as i posted previously. This function does not have a width input.

            I want to reference the Upper / Lower channel lines of this. I understand (or I think I understand) that I can use the RegressionChannel() call to find the Upper / Lower channel lines using the same period I used for DrawRegressionChannel, then referencing the .Upper / .Lower variables from RegressionChannel(). If this is true, what would I have to set the width input for RegressionChannel() to, to have the same channel.

            Basically what I'm asking is how can I create the same channel using both
            DrawRegressionChannel and RegressionChannel?

            Thanks again
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Ok. I see what you mean. The width drawn by the regression channel draw object is determined by the setting you have set for the draw object's default. Double click on the draw object to bring up the properties window. Default is 2 std devs.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Yes, that is what I was looking for.

                Thanks.
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  IRegressionChannel, DrawRegressionChannel, RegressionChannel relationship...

                  I understand.
                  Last edited by funk101; 10-05-2014, 03:42 PM. Reason: I get it now, whatever your default settings are for the indicator is what is created "on the fly"

                  Comment


                    #10
                    RegressionChannel width for Midpoint

                    So I get that you can do:

                    IRegressionChannel rchannel = DrawRegressionChannel("rchannel_", Bars.BarsSinceSession, 0, Color.Blue);

                    and what gets created is a Regression Channel that utilizes the default settings in the actual RegressionChannel indicator(in this case "2");

                    // lower
                    RegressionChannel(rchannel.StartBarsAgo, rchannel.StdDevLower).Lower[0];

                    // upper
                    RegressionChannel(rchannel.StartBarsAgo, rchannel.StdDevUpper).Upper[0];

                    // midpoint
                    RegressionChannel(rchannel.StartBarsAgo, ??); what does midpoint use as a width?

                    Do all 3 lines use the same width? In the case 2, 2, 2 for Upper, Lower and Midpoint?
                    In this example the rchannel object only has the upper and lower values exposed.

                    Comment


                      #11
                      Hello funk101,

                      Thank you for your post.

                      If you are just calling their value, they have no width. If you are adding them to the chart via Add() then they will use the default settings.

                      Comment


                        #12
                        If I remove the width as in:

                        // midpoint
                        RegressionChannel(rchannel.StartBarsAgo)[0];



                        It throws an error: "No overload method for RegressionChannel takes 1 arguments"
                        Last edited by funk101; 10-05-2014, 09:52 PM.

                        Comment


                          #13
                          Hello funk101,

                          Thank you for your response.

                          The width parameter is the number of std deviations to calculate the channel lines. This is a user configured setting, but if you are trying to use the same values as if you were calling them from the same instance of the indicator, then they would use the same value.

                          Comment


                            #14
                            So, since my default is "2" then I would use 2 for mid, lower, and upper, correct?

                            // lower
                            RegressionChannel(rchannel.StartBarsAgo, 2).Lower[0];

                            // upper
                            RegressionChannel(rchannel.StartBarsAgo,2).Upper[0];

                            // midpoint
                            RegressionChannel(rchannel.StartBarsAgo, 2);

                            Comment


                              #15
                              Hello Funk101,

                              That is correct.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jclose, Today, 09:37 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,413 views
                              0 likes
                              Last Post Traderontheroad  
                              Started by firefoxforum12, Today, 08:53 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post firefoxforum12  
                              Started by stafe, Today, 08:34 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by sastrades, 01-31-2024, 10:19 PM
                              11 responses
                              169 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X