Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Keltner Channel using ATR offset

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

    Keltner Channel using ATR offset

    Do you have a version using ATR offset, the same implementation as Stockcharts.com?

    Thanks,

    Richard

    #2
    Hi Richard,

    I have not seen this Keltner Channel on these forums, but you can check file sharing section for additional free indicators. If you are aware the exact requirements, you may consider hiring a NinjaScript consultant to code this for you:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan.

      This is the newer version of Keltner Channels, introduced by Linda Bradford Raschke in the 1980s, uses Average True Range (ATR), to set channel width. StockCharts.com uses this newer version of Keltner Channels.

      The exact requirements are as follows:



      Appreciate it very much if you can hire a NinjaScript Consultant to code this version of Ketner Channel.

      Meanwhile, I will take a stab at it.

      Thanks,

      Richard

      Comment


        #4
        Hello,

        I have sent this into development for them to consider adding to a future version of NinjaTrader: #1318 is your feature request number.

        Thank You and have a great rest of the day!
        BrettNinjaTrader Product Management

        Comment


          #5
          Originally posted by Richard168 View Post
          Thanks Ryan.

          This is the newer version of Keltner Channels, introduced by Linda Bradford Raschke in the 1980s, uses Average True Range (ATR), to set channel width. StockCharts.com uses this newer version of Keltner Channels.

          The exact requirements are as follows:



          Appreciate it very much if you can hire a NinjaScript Consultant to code this version of Ketner Channel.

          Meanwhile, I will take a stab at it.

          Thanks,

          Richard
          1. Create a new indicator by using "Save As.." in the current indicator.
          2. Replace the OnBarUpdate() event code with this:

          Code:
                  protected override void OnBarUpdate()
                  {
                      double trueRange = Math.Max(High[0], Close[1]) - Math.Min(Low[0], Close[1]);
          
                      diff.Set(trueRange);
          
                      double middle    = EMA(Typical, Period)[0];
                      double offset    = EMA(diff, Period)[0] * offsetMultiplier;
          
                      double upper    = middle + offset;
                      double lower    = middle - offset;
          
                      Midline.Set(middle);
                      Upper.Set(upper);
                      Lower.Set(lower);
                  }

          Comment


            #6
            Originally posted by koganam View Post
            1. Create a new indicator by using "Save As.." in the current indicator.
            2. Replace the OnBarUpdate() event code with this:

            Code:
                    protected override void OnBarUpdate()
                    {
                        double trueRange = Math.Max(High[0], Close[1]) - Math.Min(Low[0], Close[1]);
            
                        diff.Set(trueRange);
            
                        double middle    = EMA(Typical, Period)[0];
                        double offset    = EMA(diff, Period)[0] * offsetMultiplier;
            
                        double upper    = middle + offset;
                        double lower    = middle - offset;
            
                        Midline.Set(middle);
                        Upper.Set(upper);
                        Lower.Set(lower);
                    }
            Hi Koganam,

            Thanks so much for your suggestion. This saves me a lot of time in coding.

            I got it working by changing: "double trueRange = ...." to: "double trueRange = ATR(atrPeriod)[0];"

            Thanks again and have a great day!

            Richard

            Comment


              #7
              Originally posted by Richard168 View Post
              Hi Koganam,

              Thanks so much for your suggestion. This saves me a lot of time in coding.

              I got it working by changing: "double trueRange = ...." to: "double trueRange = ATR(atrPeriod)[0];"

              Thanks again and have a great day!

              Richard
              Fair enough. As long as you realize that what I coded is exactly what is described in the StockCharts link that you posted. I could not have anticipated your further modification to use an average of an average.

              Comment


                #8
                Originally posted by koganam View Post
                Fair enough. As long as you realize that what I coded is exactly what is described in the StockCharts link that you posted. I could not have anticipated your further modification to use an average of an average.
                Well, not quite. The ATR would be SMA(diff, Period)[0], rather than EMA(diff, Period)[0], as the ATR is calculated on SMA rather than EMA.

                Oops

                Comment


                  #9
                  New Keltner Channel code

                  After reading this thread, stockcharts.com's Keltner channel doc, and other, I adapted the original Keltner channel code and created the ATR version. ATR period can be set independent of midline period. I also used closing price (i.e. Linda Raschke version) rather than typical price. Let me know what you think.

                  slsdoug
                  Attached Files

                  Comment


                    #10
                    Hi Slsdoug,

                    Your code looks great. I checked it with Stockcharts.com and they are within $0.01 for a $45 stock.

                    Thanks again for your help.

                    Richard

                    Comment


                      #11
                      Thanks slsdoug,

                      This indicator is just what I was looking for. Is there any way you could modify the code so that the outer bands are based on the close of the prevoius bar and not an EMA?

                      Just wondering,

                      Max

                      Comment


                        #12
                        Bands based on prev close

                        The Keltner bands are based on ATR, not EMA.
                        If you use the prev close * multiplier, the bands are very far away. For example, if the ema of the S&P500 (SPY) is 135 and the prev close is 134, then the upper band will be 135+134*2.
                        I took the absolute value of the close - yesterday's close and used it. If only the close - yesterday's close is used, then the bands cross over periodically.

                        slsdoug
                        Attached Files

                        Comment


                          #13
                          Wow thx for the fast response slsdoug I should of been much more specific:

                          I saw this great indicator for Tradestation. I do believe that the the indicator works by calculating the ATR for a variable set period, it uses a multiplier to size the band channel, and then adds and subtracts the ATR*multiplier from the close of each bar. The resulting band gives you a probable maximum range of movement for the subsequent bar. Like the Keltner Channel you created the bands are based on ATR but added and subtracted from the close of each bar not from an EMA; this creates a jagged channel band instead of a smooth one, but the indicator works great!

                          Comment


                            #14
                            Interesting Banding

                            I'm not exactly sure how to interpret the bands. Any ideas?
                            Attached Files

                            Comment


                              #15
                              Originally posted by slsdoug View Post
                              I'm not exactly sure how to interpret the bands. Any ideas?
                              You use the bands as "scale-out levels"/"profit targets" if you enter a trade in either direction.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              671 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              379 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              111 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              575 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              582 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X