Announcement

Collapse
No announcement yet.

Kirshenbaum Bands

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

  • Kirshenbaum Bands

    I searched for a efs study for this indicator and couldn't find it. It is available for Metastock, Neuroshell, Omnitrader,and Tradestation though. I would love to see it coded if someone is up to it.

    Here is a description...

    Paul Kirshenbaum, a money manager and mathematician with a Ph.D. in economics from NYU, submitted this rather unique trading band which is “de-trended.” The Kirshenbaum Bands are similar to Bollinger bands in usage, however are widely considered to be superior.

    Kirshenbaum Bands are similar to Bollinger Bands (see BOL-C) in that they measure market volatility. However, rather than use standard deviation of a moving average for band width, they use the standard error of linear regression lines of the close. This has the effect of measuring volatility around the current trend, instead of measuring volatility for changes in trend.

    Construction:

    Kirshenbaum Bands are constructed as follows:

    Calculate a P-Period Exponential Moving Average of the data based on the close.

    Then, for each bar, calculate the L-Period linear regression line, using today’s close as the endpoint of the line. (Note: The term “linear regression” is the same as a “least squares” or “best fit” line in some textbooks.)

    Calculate d1, d2, d3, .. dL as the distance from the line to the close on each bar which was used to derive the line. That is, di = Distance from Regression Line to each bar’s close.

    Calculate the average of the squared errors:

    AE = (d12 + d22 + d32 + .. + dN2) / L

    Standard Error (Se) is the square root of this value:

    Se = square root of AE

    Then, if N = Number of Standard Errors, band width is:

    BW = N * SE

    Add and subtract the band width from the Exponential Moving Average to arrive at today’s value for the upper and lower bands.

    Parameters:

    Periods (P): The period used in the Exponential Moving Average calculation.

    Linear Regression Periods (L): The period used in constructing the lines for Linear Regression.

    Deviations (N): Number of deviations used. That is, the Standard Error value can be multiplied by a factor to expand the bands. Mr. Kirshenbaum recommends a value of 1.75.

    Trading System:

    This system trades when the price moves outside the K-Bands with the close inside the band.


    KBA-C: Kirshenbaum Bands

    Kirshenbaum Bands yield excellent volatility bands. Compare this systems with the Bollinger Bands. Use Kirshenbaum bands to measure volatility around a trend, and Bollinger Bands to measure changes in trend.

  • #2
    This would be great

    This would be great. Import study that would enhance the range of available studies. Somrthing I want too.

    Comment


    • #3
      Kirshenbaum Bands script uploaded to Specialty Scripts group in File Share area. It is in the Miscellaneous folder.

      Chris

      Comment


      • #4
        Thanks again Chris, works perfectly!

        Comment


        • #5
          I believe that your script performing the computation of Standard Error is incorrect. Please see this thread for an overview.



          The code should be corrected thus:-

          /////////////////////////
          function OrderPoints( points ) {
          var a,b,c,d;
          var b0,b1;
          var x;

          a=b=c=d=0;

          x=0;
          for(x = 0; x < points; x++) {
          a += x;
          c += x*x;
          b += close(-x);
          d += x * close(-x);
          }

          b1 = (a*b - points*d)/(a*a - points*c);
          b0 = (b - (b1*a))/points;

          return new Array ( b0, b1 );
          }

          //////////////////////
          From main

          nVal1 = OrderPoints( LPeriod );

          nSlope = nVal1[1]
          nIntercept = nVal1[0]

          nTmp = nSum = x = 0;

          while ( x<LPeriod ) {

          nTmp = (nIntercept + (nSlope * x));
          nSum += ( close(-x) - nTmp ) * ( close(-x) - nTmp );
          x++;
          }


          nSE = Math.sqrt( nSum/ (LPeriod-2));

          Hope this info was useful. Note that OrderPoints function was changed as intercept value(b0) was incorrect.


          Robert

          Comment


          • #6
            Robert:

            Thanks, but I have to disagree. As far as I can tell, the linear regression calc (OrderPoints) is indeed correct.

            Take a 5-day regression of IBM Daily. Using a math textbook or any of myriad of linear regression tools available on the web, I get:

            88.63
            89.66
            89.43
            89.91
            90.54

            as my 5 data points (IBM Daily data)

            y=mx+b
            y=0.407*5 + 88.413
            y=90.448 (rounded)

            Run that same test using OrderPoints and the slope and intercept match up exactly.

            Now, is the Kirshenbaum calculation correct?? I don't know for sure. I do know that it is an accurate representation of the logic that was provided to me to create the script.

            Chris

            Comment


            • #7
              The problem with your calculation is that you are multiplying by 5 instead of 4 which is (nPeriod-1) and not computing the linear regression starting at 0 which is the current bar. The intercept in this case is 88.82. However the final linear regression value will
              be the same as the slope is the same in both cases (allowing for rounding errors):-

              0.407*4+88.82 = 0.407*5+88.41

              I have changed the formula to ensure that 0 is used as the first value for the counter x to match the bar count values used in close() etc...

              Concerning the logic presented on Kirshenbaum you missed the section in your coding:-

              "Calculate d1, d2, d3, .. dL as the distance from the line to the close on each bar which was used to derive the line. That is, di = Distance from Regression Line to each bar’s close"

              which I have included in the loop using :-

              nTmp = (nIntercept + (nSlope * x));
              nSum += ( close(-x) - nTmp ) * ( close(-x) - nTmp );

              By the way this is the precise logic used to compute any standard error using linear regression.

              The final averaging is divided by (nPeriod-2) to give an unbiased result as normally required in Standard Error computations.

              I have got heavily involved with matter as I was coding an auto regression tool to replace that of eSignal's in my trading activities, where I have discovered yet another error by eSignal in their methodology computations. I was also looking at various methods of producing bands and channels using linear regression and came across your script.

              Robert

              Comment


              • #8
                Robert:

                Thanks. I see the issue now. I will post a new version shortly.

                Chris

                Comment


                • #9
                  Robert one question

                  Since I use heavily Kirshenbaum, this let's say @non totally orthodox t@ intrepretation how much affect the results of the 3 bands?

                  I have two basic tools in any chart and from there I always start:

                  RTC of AGET

                  and secondarely KIRSHENBAUM

                  You already did a lot, but can you post two charts in order to show the differences?

                  Thanks a lot.
                  Fabrizio L. Jorio Fili

                  Comment


                  • #10
                    Fabrizio:

                    Please find attached the newly coded script with all the revisions that I have described.

                    Next up will be a comparison chart using both scripts.

                    Robert
                    Attached Files

                    Comment


                    • #11
                      Here is a chart showing today's action on the Dow Jones Mini Futures with both scripts in play. The basis in red is the same for both. The cyan lines represent the new coding and the dark blue lines represent the previous version.

                      As you can see there is a substantial difference between the 2 which gives completely different interpretations. It may be that the origianl version suits your current purposes.

                      What I am after is what the developer put together so that I can analyze the criteria for trading purposes, to see whether I should use this methodology or not. I do not want to formulate any new concepts at this time only to fully review each methodology based strictly on the originator's/developer's criteria, observations and interpretations.


                      Robert
                      Attached Files

                      Comment


                      • #12
                        Thank You Robert

                        And Thank you to Chris that provide us with great tools

                        Thanks again to both.
                        Fabrizio L. Jorio Fili

                        Comment


                        • #13
                          If anyone is interested in exploring other bands such as Anderson, Bollinger, Headley, Keltner, Kirshenbaum & Stoller with a "twist" please have a look at the following thread:-



                          Robert

                          Comment

                          Working...
                          X