Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Regression Channel Trailing chart

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

    Regression Channel Trailing chart

    Hi,

    Can someone please help me to develop a trailing indicator of Upper/Middle/Lower values of a Regression Channel?

    I need to recognize that my programming skills are -0.1, sorry.

    I am attaching a manual drawing of the way I see this indicator working. The brown line in the picture is the trailing plot of the Upper value of a Regression Channel (18 Bars, 2 Std Dev). The same would be for the Middle and Lower values.

    * Note that I am leaving all the Regression Channels from the previous bars for demonstration purposes, the channels would not show up, only the Brown line shown in the picture for the corresponding Upper/Middle/Lower values.

    I think the variables to select for the Reg Channel should be: the Std Dev to use (2,3, etc.), the Price type (OHLC), the Period (# of Bars).

    Thanks in advance. I promise to share how to use it if I find it beneficial after testing it with real trades.

    HJS
    Attached Files

    #2
    If no one is willing to help, you can consider a NinjaScript consultant. Link to list below.

    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by HJSInvesting View Post
      Hi,

      Can someone please help me to develop a trailing indicator of Upper/Middle/Lower values of a Regression Channel?


      HJS
      This looks like a pair of Bollinger Bands, but using the regression rather than the moving average as the centre line.

      If so, perhaps it's worth trying the following:
      a) copy the existing Bollinger Band indicator source code file, and call it say "BollingerLinReg.cs"
      b) change the indicator name "Bollinger" everywhere it appears in the source code to your own name, i.e. "BollingerLinReg".
      c) change the 3 lines in the OnBarUpdate function that refer to the SMA to refer instead to LinReg. Just a simple text substitution of "LinReg" for "SMA".

      I tried it, and it works fine, although there are a few dozen subsititutions of "Bollinger" to "BollingerLinReg" to perform so it's a bit tedious.

      Alternatively, create your own brand new indicator using the Wizard with the appropriate parameters (Period, NumStdDev etc) exactly as for the standard Bollinger Band indicator, set Overlay = true, PriceTypeSupported = true, and when it has all been created, just copy the following 3 lines into the OnBarUpdate method, replacing everything that's already in there.

      Upper.Set(LinReg(Period)[0] + NumStdDev * StdDev(Period)[0]);
      Middle.Set(LinReg(Period)[0]);
      Lower.Set(LinReg(Period)[0] - NumStdDev * StdDev(Period)[0]);

      Good luck
      Peter

      Comment


        #4
        Peter,

        Thanks a lot for the suggestion. I tried it but the new bands do not quite follow the Reg Channels limits as in the picture that I sent. The new bands expand way farther than the Upper/Lower limits that the Regression Channel would create.

        In fact that is the reason why I think this may be useful, because it would "filter" a lot of the variability that Bollinger bands usually show.

        HJS

        Comment


          #5
          Originally posted by HJSInvesting View Post
          Peter,

          Thanks a lot for the suggestion. I tried it but the new bands do not quite follow the Reg Channels limits as in the picture that I sent. The new bands expand way farther than the Upper/Lower limits that the Regression Channel would create.

          In fact that is the reason why I think this may be useful, because it would "filter" a lot of the variability that Bollinger bands usually show.

          HJS
          HJS,

          The picture doesn't indicate how the channel lines were created so I assumed from your text that they use a StdDev calculation. If they use some other method, then a similar technique could be applied using a different channel calculation.

          For example, if you prefer a multiple of ATR then maybe you could try instead (although the pedantic would now say that this is not Bollinger any more, so a different indicator name could be invented):

          Upper.Set(LinReg(Period)[0] + NumStdDev * ATR(Period)[0]);
          Middle.Set(LinReg(Period)[0]);
          Lower.Set(LinReg(Period)[0] - NumStdDev * ATR(Period)[0]);



          Cheers
          Peter

          Comment


            #6
            Thanks Peter, good point. Or the Standard Error, which is often used in combination with Linear Regression - http://www.ninjatrader-support.com/H...dardError.html

            You might also want to consider the Standard Errors Bands Smoothed as trailing stop levels, please find the script attached.
            Attached Files

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Thanks Peter, good point. Or the Standard Error, which is often used in combination with Linear Regression - http://www.ninjatrader-support.com/H...dardError.html

              You might also want to consider the Standard Errors Bands Smoothed as trailing stop levels, please find the script attached.
              Ah - excellent and elegant!

              Peter

              Comment


                #8
                Thanks Peter and Bertrand.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                574 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                332 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