PureBytes Links
Trading Reference Links
|
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
Attachment Converted: "c:\eudora\attach\PolyFit1.DLL"
|