Polynomials and JM Hurst

Discussion in 'Technical Analysis' started by hoo_doo_one, May 31, 2006.

  1. I know that this has been tried in the past, but has anyone out there tried to use polynomial extrapolation to project Hurst channels?

    I've played around with curvilinear envelopes in the past but dismissed their usefulness and got rid of the Easy Language code. I'd like to re-evaluate the code but I can't seem to find it anymore.

    Does anyone out there have any polynomial regression code in Easy Language?

    -Hoo_doo
     
  2. bgp

    bgp

    wealth lab has the code for hurst.

    bgp
     
  3. Thanks bgp,

    Unfortunately, I'm using TS2000i and the wealthlab code isn't much help to me at the moment. I may end up breaking down and witting the ez code myself. I just thought I'd check to see if anyone had any ez code for polynomials.

    -Hoo_doo
     
  4. Ah ha! It's not exactly what I was looking for but it's very close none the less.

    Thanks once again to Clyde Lee.

    Here's the code if anyone is interested along with a screen shot...

    {
    Function: PolyFit_Proj
    }

    {

    Conversion: NumericalMethods FORTRAN to EasyLanguage

    Author of Conversion: Clyde Lee
    www.theswingmachine.com
    clydelee@swbell.net

    Permission to use copy distribute granted so long
    as credit for conversion is appended.
    }


    { PROGRAM LPOLYNOM}
    {C ----------------------------------------------------------------}
    {C Alg5"2.for FORTRAN program for implementing Algorithm 5.2}
    {C }
    {C NUMERICAL METHODS: FORTRAN Programs, (c) John H. Mathews 1995}
    {C To accompany the text:}
    {C NUMERICAL METHODS for Math., Science & Engineering, 2nd Ed, 1992}
    {C Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.AX.}
    {C Prentice Hall, Inc.; USA, Canada, Mexico ISBN 0-13-624990-6}
    {C Prentice Hall, International Editions: ISBN 0-13-625047-5}
    {C This free software is compliments of the author.}
    {C E-mail address: in%"mathews@fullerton.edu"}
    {C }
    {C Algorithm 5.2 (Least Squares Polynomial).}
    {C Section 5.2, Curve Fitting, Page 278}
    {C ----------------------------------------------------------------}

    {
    SUBROUTINE SOLVELI(Price,NumPoint,AX,BX,DegPoly,CX)
    INTEGER Col,IX,JX,KX,DegPoly,IP,RX,Row,T
    REAL AX,BX,CX,XX,Price,PX,Sum,Pow,Prod,XK,YK,Err,Z1
    DIMENSION AX(1:8,1:8),BX(1:8),CX(1:8),Price(1:53)
    DIMENSION Row(1:7),ZX(1:7)
    DIMENSION Pow(0:14)
    }

    Input: Price(C), {Price data to fit polynomial to and project }
    DegPoly(3), {Degree of polynomial to fit -- max=7 }
    ChanWidth(5), {Percent of price to setup for channel lines }
    {Negative = multiplier of 21 bar AvgTrueRange}
    NumPoint(25), {Number of data points to use in fit--max=53 }
    NPointPd(0); {Number of points forward to predict price }
    Input: EndDate(0); {Ending date for computation of coefficients }
    {
    SmoLeng(0); {Number of points in T3Average filter }
    }


    Array: CoefAry[12](0);
    Vars: EndKnt(0), IsEnd(False), HoldBar(0), ATR21(AvgTrueRange(21)),
    ChanWide(0), ChanMult(Iff(ChanWidth<0,-ChanWidth,ChanWidth*.01));

    If EndKnt=0 Or IsEnd=False then Value1=PolyFit_Project(Price, DegPoly, NumPoint, NPointPd);

    IsEnd = Date>EndDate and EndDate<>0;
    If ChanWidth<0 then begin
    ATR21=AvgTrueRange(21);
    ChanWide=ATR21*ChanMult;
    End
    Else ChanWide=Average(c,51)*ChanMult;


    {
    If SmoLeng>0 then Value2=T3Average(Value1,SmoLeng)
    Else Value2=Value1;

    If SmoLeng>0 then begin
    Value2=Average(Value1,SmoLeng);
    Plot2[-NPointPd+IntPortion(SmoLeng/2+.5)](Value2,"CMA");
    End;
    }

    If IsEnd and LastBarOnChart=False then begin
    If HoldBar=0 then HoldBar=CurrentBar;
    Value1=PolyFit_Project(Price, DegPoly, NumPoint, CurrentBar-HoldBar);
    Plot1[-(CurrentBar-HoldBar)-NPointPd](Value1,"EstPrice");
    End
    Else If LastBarOnChart then begin
    If HoldBar=0 then HoldBar=CurrentBar;
    If EndKnt<MaxBarsForward then begin
    EndKnt=0;
    For Value2=0 downto -(MaxBarsForward-NPointPd) begin
    Value1=PolyFit_Project(Price, DegPoly, NumPoint, CurrentBar-HoldBar+EndKnt+NPointPd);
    Plot1[-(CurrentBar-HoldBar)-EndKnt-NPointPd](Value1,"EstPrice");
    Plot2[-(CurrentBar-HoldBar)-EndKnt-NPointPd](Value1+ChanWide,"Est+C");
    Plot3[-(CurrentBar-HoldBar)-EndKnt-NPointPd](Value1-ChanWide,"Est-C");
    EndKnt=EndKnt+1;
    End;
    End;
    End
    Else begin
    Plot1[-NPointPd](Value1,"EstPrice");
    Plot2[-NPointPd](Value1+ChanWide,"Est+C");
    Plot3[-NPointPd](Value1-ChanWide,"Est-C");
    End;