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

PROG - TS code and .ela for Pivot related system



PureBytes Links

Trading Reference Links

<x-html><HTML>
TS and SC Traders

<P>Recently&nbsp; jdundee@xxxxxxxxxxxxxxx&nbsp; has reminded up of Pivots.

<P>For a number of years I have looked on Pivots and the associated
<BR>Resistance/Support zones with interest.

<P>I finally decided to do something about it and used one of the indicators
<BR>which I had which showed the R1, R2, S1, S2 points.

<P>I am a short term position trader (mostly ED, JY, and OEX) and I did
<BR>not quite see how this was of help but I wondered what things would
<BR>look like if I averaged the R1R2 values and then did an XAverage of
<BR>these averages.&nbsp; Also the same for the S1S2 values.

<P>I am attaching a&nbsp;&nbsp; .ela&nbsp;&nbsp; file with this indicator
in it -- different lengths
<BR>for R1R2 and S1S2 can be input.&nbsp; (Code is also listed below for
<BR>those "cut and paste" fans.)

<P>From this I got the idea that something might be viable as a short
<BR>(or maybe long) term position trading system after I noticed that
<BR>once High prices tended to remain over the R1R2 average lines for
<BR>a number of days then the prices seemed to be in a trend and continue
<BR>higher.&nbsp; Same appeared true for Low price below S1S2 average
<BR>lines.

<P>The attached&nbsp;&nbsp; .ela&nbsp;&nbsp; file also contains a system
that makes use of
<BR>this observation.&nbsp; The system worked pretty good from 1980 to
<BR>now on the JY and seems to be applicable for the OEX.&nbsp; I have
<BR>NOT done extensive testing of the parameters and/or type of equity
<BR>to which this is applied so you had better investigate yourself.

<P><TT>This is info that I have for period 1980 to 1997:</TT>
<BR><TT>JY&nbsp;&nbsp;&nbsp; $129,728&nbsp;&nbsp;&nbsp;&nbsp; 940%</TT>
<BR><TT>BP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 84,961&nbsp;&nbsp;&nbsp;&nbsp;
391%</TT>
<BR><TT>DM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 59,358&nbsp;&nbsp;&nbsp;&nbsp;
364%</TT>
<BR><TT>SF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 66,038&nbsp;&nbsp;&nbsp;&nbsp;
350%</TT>
<BR><TT>US&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 49,645&nbsp;&nbsp;&nbsp;&nbsp;
274%</TT><TT></TT>

<P><TT>All were run with same parameters as JY (which</TT>
<BR><TT>had been optimized).&nbsp; An optimization of US</TT>
<BR><TT>resulted in $81,095 / 526%.</TT><TT></TT>

<P><TT>These are pretty robust figures I would think! ! ! !</TT><TT></TT>

<P><TT>Code for indicators, functions, and system are below.</TT><TT></TT>

<P><TT>CODE (TS) FOR INDICATOR - - - - - - - - - - - - - - - - - -</TT><TT></TT>

<P><TT>Input: LenAvgR(5),LenAvgS(5);</TT><TT></TT>

<P><TT>Value1=LeePivotR12Average(LenAvgR)[1];</TT>
<BR><TT>Value2=LeePivotS12Average(LenAvgS)[1];</TT>
<BR><TT>If Value2>Value1 then Value2=LeePivotS12Average(LenAvgR)[1];</TT><TT></TT>

<P><TT>Plot1(Value1,"Res");</TT>
<BR><TT>Plot2(Value2,"Supt");</TT>
<BR><TT>Plot3((Value1+Value2)*.5,"Pivot");</TT><TT></TT>

<P><TT>CODE (TS) FOR NECESSARY FUNCTIONS - - - - - - - - - - - - -</TT><TT></TT>

<P><TT>{ *******************************************************************</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;Function&nbsp; : LeePivotR12Average</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;Last Edit : 9/25/97</TT><TT></TT>

<P><TT>&nbsp;Provided By : Clyde Lee,Futursmagic (c) Copyright 1997</TT><TT></TT>

<P><TT>&nbsp;Function called with length of exponential average to</TT>
<BR><TT>&nbsp;compute Average of average of the well know</TT>
<BR><TT>&nbsp;Pivot/Support/Resistence points.</TT>
<BR><TT>&nbsp; Resistance 1</TT>
<BR><TT>&nbsp; Resistance 2</TT>
<BR><TT>&nbsp;levels of commodity prices.</TT><TT></TT>

<P><TT>&nbsp;Values derived are for use in evaluation of TOMORROWS</TT>
<BR><TT>&nbsp;price support/resistance points.</TT><TT></TT>

<P><TT>********************************************************************}</TT><TT></TT>

<P><TT>Inputs:&nbsp; Length(NumericSimple);</TT><TT></TT>

<P><TT>Vars:&nbsp; Pivot(0),R1(0),R2(0),S1(0),S2(0);</TT>
<BR><TT>Vars:&nbsp; XAlpha(2/(Length+1)),XBeta(1-Xalpha),XAvgR12(C);</TT><TT></TT>

<P><TT>Pivot = ((O+H+L+C)*.25);</TT>
<BR><TT>R1 = (2*Pivot)-L;</TT>
<BR><TT>S1 = (2*Pivot)-H;</TT>
<BR><TT>R2 = Pivot-(S1-R1);</TT>
<BR><TT>{S2 = Pivot-(R1-S1);}</TT><TT></TT>

<P><TT>XAvgR12=XavgR12*XBeta+(R1+R2)*.5*XAlpha;</TT><TT></TT>

<P><TT>LeePivotR12Average=XAvgR12;</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>{ *******************************************************************</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;Function&nbsp; : LeePivotS12Average</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;Last Edit : 9/25/97</TT><TT></TT>

<P><TT>&nbsp;Provided By : Clyde Lee,Futursmagic (c) Copyright 1997</TT><TT></TT>

<P><TT>&nbsp;Function called with length of exponential average to</TT>
<BR><TT>&nbsp;compute Average of average of the well know</TT>
<BR><TT>&nbsp;Pivot/Support/Resistence points.</TT>
<BR><TT>&nbsp; Support 1</TT>
<BR><TT>&nbsp; Support 2</TT>
<BR><TT>&nbsp;levels of commodity prices.</TT><TT></TT>

<P><TT>&nbsp;Values derived are for use in evaluation of TOMORROWS</TT>
<BR><TT>&nbsp;price support/resistance points.</TT><TT></TT>

<P><TT>********************************************************************}</TT><TT></TT>

<P><TT>Inputs:&nbsp; Length(NumericSimple);</TT><TT></TT>

<P><TT>Vars:&nbsp; Pivot(0),R1(0),R2(0),S1(0),S2(0);</TT>
<BR><TT>Vars:&nbsp; XAlpha(2/(Length+1)),XBeta(1-Xalpha),XAvgS12(C);</TT><TT></TT>

<P><TT>Pivot = ((O+H+L+C)*.25);</TT>
<BR><TT>R1 = (2*Pivot)-L;</TT>
<BR><TT>S1 = (2*Pivot)-H;</TT>
<BR><TT>{R2 = Pivot-(S1-R1);}</TT>
<BR><TT>S2 = Pivot-(R1-S1);</TT><TT></TT>

<P><TT>XAvgS12=XAvgS12*XBeta+(S1+S2)*.5*XAlpha;</TT><TT></TT>

<P><TT>LeePivotS12Average=XAvgS12;</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>CODE FOR SYSTEM FOLLOWS:- - - - - - - - - - - - - - - - - -</TT><TT></TT>

<P><TT>{</TT>
<BR><TT>&nbsp;System LeePivotMOVA</TT><TT></TT>

<P><TT>&nbsp;Trading system written by:</TT>
<BR><TT>&nbsp;Clyde Lee (FuturesMagic) Copyright (c) 1997</TT>
<BR><TT>&nbsp;clydelee@xxxxxxx</TT><TT></TT>

<P><TT>&nbsp;System LeePivotMOVA - System counts how many times in the
past</TT>
<BR><TT>&nbsp;NBar2Cnt bars (including current one) that High price has
been</TT>
<BR><TT>&nbsp;above the XAverage of length LengH of the average of the
R1 AND R2</TT>
<BR><TT>&nbsp;(resistance levels computed by pivot computation).&nbsp;
Time periods of</TT>
<BR><TT>&nbsp;7 to 10 bars seem to work pretty good.</TT><TT></TT>

<P><TT>&nbsp;System also counts how many times in this same period the
Low price</TT>
<BR><TT>&nbsp;has been below the XAverage of length LengL of the average
of the</TT>
<BR><TT>&nbsp;S1 AND S2 (support levels computed by pivot computation).</TT><TT></TT>

<P><TT>&nbsp;When the number of high counts minus the low counts exceedes</TT>
<BR><TT>&nbsp;or is equal to the value CntDiff then the system attempts
to</TT>
<BR><TT>&nbsp;buy the next day at the average of the R12 AND S12 average</TT>
<BR><TT>&nbsp;values.&nbsp; To sell the low count must have the same difference</TT>
<BR><TT>&nbsp;over the high count.&nbsp; A difference of 2 or 3 or 4 seems
to be</TT>
<BR><TT>&nbsp;ideal for most vehicles.</TT><TT></TT>

<P><TT>&nbsp;An enddate of 999999 will cause system to close all positions</TT>
<BR><TT>&nbsp;on last bar of file.&nbsp; Don't set to this if running real
life!!!</TT><TT></TT>

<P><TT>$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$</TT>
<BR><TT>}</TT><TT></TT>

<P><TT>inputs:&nbsp;&nbsp;&nbsp;&nbsp; LengH(7),&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{Length for Resistance XAverage}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
LengL(10),&nbsp;&nbsp;&nbsp;&nbsp; {Length for Support&nbsp;&nbsp;&nbsp;
XAverage}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NBar2Cnt(10),&nbsp; {Number of bars to use in over/under count}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CntDiff(3),&nbsp;&nbsp;&nbsp; {Difference in over resistance and</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
under support for a good trade}</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
BegDate(650101),EndDate(991231);</TT><TT></TT>

<P><TT>Vars:&nbsp;&nbsp; UPCnt(0),DNCnt(0),RawCnt(0);</TT>
<BR><TT>Vars:&nbsp;&nbsp; TPHigh(0),TPLow(0);</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>&nbsp;TPHigh=LeePivotR12Average(LengH);</TT>
<BR><TT>&nbsp;TPLow =LeePivotS12Average(LengL);</TT>
<BR><TT>&nbsp;If TPLow>TPHigh then TPLow=LeePivotS12Average(LengH);</TT>
<BR><TT>&nbsp;RawCnt=RawCnt+1;</TT><TT></TT>

<P><TT>If Date>=BegDate and Date&lt;EndDate and RawCnt>15 then begin</TT><TT></TT>

<P><TT>&nbsp;Value2=(TPHigh+TPLow)*.5;</TT>
<BR><TT>&nbsp;ExitLong&nbsp; TPLOw&nbsp;&nbsp; stop;</TT>
<BR><TT>&nbsp;ExitShort TPHIgh&nbsp; stop;</TT><TT></TT>

<P><TT>&nbsp;UPCnt=0;DNCnt=0;</TT>
<BR><TT>&nbsp;For Value1=0 to NBar2Cnt-1 Begin</TT>
<BR><TT>&nbsp; If L[Value1]&lt;=TPLow[Value1]&nbsp; then DNCnt=DNCnt+1;</TT>
<BR><TT>&nbsp; If H[Value1]>=TPHigh[Value1] then UPCnt=UPCnt+1;</TT>
<BR><TT>&nbsp;End;</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;Value3=UPCnt-DNCnt;</TT>
<BR><TT>&nbsp;If Value3>=+CntDiff then buy&nbsp; ("TPLong")&nbsp; at Value2
stop;</TT>
<BR><TT>&nbsp;If Value3&lt;=-CntDiff then sell ("TPShort") at Value2 stop;</TT><TT></TT>

<P><TT>End;</TT><TT></TT>

<P><TT>If (LastBarOnChart=True and EndDate=999999) or&nbsp; Date>=EndDate
then&nbsp; begin</TT>
<BR><TT>&nbsp;If marketposition =&nbsp; 1 then exitlong {("exl") at Market};</TT>
<BR><TT>&nbsp;If marketposition = -1 then exitshort{("exs") at Market};</TT>
<BR><TT>End;</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>END OF CODE FOR SYSTEM</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;
<BR>&nbsp;</HTML>
</x-html>
Attachment Converted: "c:\eudora\attach\Leepivot.ela"

Attachment Converted: "c:\eudora\attach\vcard69.vcf"