[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exponential moving average



PureBytes Links

Trading Reference Links

At 3:02 PM -0700 9/30/00, Bob Perry wrote:

>I was wondering if anyone has coded these second and third order
>regression lines, either as an ELA or DLL? It would be way beyond my
>ability to try. What I am looking for is what Bob Fulks (great post,
>by the way!) calls a "polynomial moving average" like in an Excel
>chart. Is this too compicated for TS? Is there a better way?

Andrew Peskin posted a PolyFit DLL and ELA on November 5, 1999.

The message and DLL and ELA are attached it two additional messages.

Bob Fulks

----------

>From Code-request@xxxxxxxxxxxxx  Fri Nov  5 18:35:30 1999
Date: Fri, 05 Nov 1999 18:34:20 -0500
From: Andrew Peskin <Andrew@xxxxxxxxx>
Reply-To: Andrew@xxxxxxxxx
To: omega-list@xxxxxxxxxx, code-list@xxxxxxxxxxxxx, realtraders@xxxxxxxxxxxx
Subject: CL_Polynomial Fit & Projection -- Function, Indicator, & DLL for TS2000i

I would first like to thank Clyde Lee for posting the EL code for the
Polynomial Fitting Function earlier today.  As hinted to in his post, I
have taken that code and created a DLL for it (it greatly reduces the
computational time).  Below is the EL code for both the Indicator and
Wrapper Function for the DLL.  You can bypass the wrapper function
altogether and insert the code from the function directly into your own
systems or indicators if you choose to save on overhead.

{-------------------------------------------------------------------------------}

{================================================================
 Indicator:    PolyFit_ProjDLL_Ind
 Date:         5 November 1999
================================================================}
Inputs:     Price(c),
            NDegree(5),
            NPoints(35),
            NProjct(2);

Vars:       PolyFit(0);

PolyFit = PolyFit_ProjDLL(Price, NDegree, NPoints, NProjct);

IF ( CurrentBar > ( 2 * NPoints ) ) THEN
BEGIN
    Plot1[-Nprojct] (PolyFit, "PF_Proj");
END;

{-------------------------------------------------------------------------------}

{================================================================
 Function:   PolyFit_ProjDLL
 Date:       5 November 1999
 Purpose:    Provide a 'wrapper' for DLL call to make it simple for
             users.
 Notes:      Users should be directed to save  PolyFit.DLL  at address:
               C:\Program Files\Omega Research\program\PolyFit.DLL
             which is what is referenced here.
================================================================}
Inputs:     Price(NumericSeries),
            NDegree(Numeric),
            NPoints(Numeric),
            NProjct(Numeric);

VARS:   PolyFit (0);            { OUTPUT FROM the DLL function. }

DefineDLLFunc: "C:\Program Files\Omega Research\program\PolyFit.DLL",
INT, "PolyNomialFit",
     FLOAT,   {Price}
     FLOAT,   {Degree of Polynomial to Fit -- Max Value = 7}
     FLOAT,   {Number of DATA points TO use IN fit}
     FLOAT,   {Number of points forward TO predict price}
     LPFLOAT; {Address}

Value1 = PolyNomialFit(
                        Price,   {Price to fit}
                        NDegree, {Degree Polynomial}
                        NPoints, {Use x Data Points for the Fit}
                        NProjct, {Project Value x Bars in the}
                        &PolyFit
                      );

PolyFit_ProjDLL = PolyFit;
{-------------------------------------------------------------------------------}

Dll is Attached.  It is 32 Bit and will only work with TS2000i.  I did
not see much need to compile a 16 bit version since there is already a
16 bit DLL floating around which dies roughly the same thing.

There is one modification to the code from Clyde's original code.

Clydes Code:       YK=Price[KX];

My Code: YK=Price[KX-1];

This is the result of a conversation with Clyde.

This as well as different levels of precision will make the results you
see with the DLL slightly different than the ones with the compiled EL
code posted earlier.

I hope you enjoy this, it looks very promising.

Andrew

Content-Type: application/octet-stream;
 name="PolyFit.DLL"
Content-Disposition: attachment;
 filename="PolyFit.DLL"