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

Re: PROG - TS code and .ela for Pivot related system



PureBytes Links

Trading Reference Links

Very interesting post from Clyde Lee,
does anyone know the code for Metastock ?
It could help a lot
Thanks for your help
Mark

Clyde Lee wrote:
> 
> TS and SC Traders
> 
> Recently  jdundee@xxxxxxxxxxxxxxx  has reminded up of Pivots.
> 
> For a number of years I have looked on Pivots and the associated
> Resistance/Support zones with interest.
> 
> I finally decided to do something about it and used one of the
> indicators
> which I had which showed the R1, R2, S1, S2 points.
> 
> I am a short term position trader (mostly ED, JY, and OEX) and I did
> not quite see how this was of help but I wondered what things would
> look like if I averaged the R1R2 values and then did an XAverage of
> these averages.  Also the same for the S1S2 values.
> 
> I am attaching a   .ela   file with this indicator in it -- different
> lengths
> for R1R2 and S1S2 can be input.  (Code is also listed below for
> those "cut and paste" fans.)
> 
> From this I got the idea that something might be viable as a short
> (or maybe long) term position trading system after I noticed that
> once High prices tended to remain over the R1R2 average lines for
> a number of days then the prices seemed to be in a trend and continue
> higher.  Same appeared true for Low price below S1S2 average
> lines.
> 
> The attached   .ela   file also contains a system that makes use of
> this observation.  The system worked pretty good from 1980 to
> now on the JY and seems to be applicable for the OEX.  I have
> NOT done extensive testing of the parameters and/or type of equity
> to which this is applied so you had better investigate yourself.
> 
> This is info that I have for period 1980 to 1997:
> JY    $129,728     940%
> BP      84,961     391%
> DM      59,358     364%
> SF      66,038     350%
> US      49,645     274%
> 
> All were run with same parameters as JY (which
> had been optimized).  An optimization of US
> resulted in $81,095 / 526%.
> 
> These are pretty robust figures I would think! ! ! !
> 
> Code for indicators, functions, and system are below.
> 
> CODE (TS) FOR INDICATOR - - - - - - - - - - - - - - - - - -
> 
> Input: LenAvgR(5),LenAvgS(5);
> 
> Value1=LeePivotR12Average(LenAvgR)[1];
> Value2=LeePivotS12Average(LenAvgS)[1];
> If Value2>Value1 then Value2=LeePivotS12Average(LenAvgR)[1];
> 
> Plot1(Value1,"Res");
> Plot2(Value2,"Supt");
> Plot3((Value1+Value2)*.5,"Pivot");
> 
> CODE (TS) FOR NECESSARY FUNCTIONS - - - - - - - - - - - - -
> 
> { *******************************************************************
> 
>  Function  : LeePivotR12Average
> 
>  Last Edit : 9/25/97
> 
>  Provided By : Clyde Lee,Futursmagic (c) Copyright 1997
> 
>  Function called with length of exponential average to
>  compute Average of average of the well know
>  Pivot/Support/Resistence points.
>   Resistance 1
>   Resistance 2
>  levels of commodity prices.
> 
>  Values derived are for use in evaluation of TOMORROWS
>  price support/resistance points.
> 
> ********************************************************************}
> 
> Inputs:  Length(NumericSimple);
> 
> Vars:  Pivot(0),R1(0),R2(0),S1(0),S2(0);
> Vars:  XAlpha(2/(Length+1)),XBeta(1-Xalpha),XAvgR12(C);
> 
> Pivot = ((O+H+L+C)*.25);
> R1 = (2*Pivot)-L;
> S1 = (2*Pivot)-H;
> R2 = Pivot-(S1-R1);
> {S2 = Pivot-(R1-S1);}
> 
> XAvgR12=XavgR12*XBeta+(R1+R2)*.5*XAlpha;
> 
> LeePivotR12Average=XAvgR12;
> 
> 
> 
> 
> 
> 
> { *******************************************************************
> 
>  Function  : LeePivotS12Average
> 
>  Last Edit : 9/25/97
> 
>  Provided By : Clyde Lee,Futursmagic (c) Copyright 1997
> 
>  Function called with length of exponential average to
>  compute Average of average of the well know
>  Pivot/Support/Resistence points.
>   Support 1
>   Support 2
>  levels of commodity prices.
> 
>  Values derived are for use in evaluation of TOMORROWS
>  price support/resistance points.
> 
> ********************************************************************}
> 
> Inputs:  Length(NumericSimple);
> 
> Vars:  Pivot(0),R1(0),R2(0),S1(0),S2(0);
> Vars:  XAlpha(2/(Length+1)),XBeta(1-Xalpha),XAvgS12(C);
> 
> Pivot = ((O+H+L+C)*.25);
> R1 = (2*Pivot)-L;
> S1 = (2*Pivot)-H;
> {R2 = Pivot-(S1-R1);}
> S2 = Pivot-(R1-S1);
> 
> XAvgS12=XAvgS12*XBeta+(S1+S2)*.5*XAlpha;
> 
> LeePivotS12Average=XAvgS12;
> 
> 
> 
> CODE FOR SYSTEM FOLLOWS:- - - - - - - - - - - - - - - - - -
> 
> {
>  System LeePivotMOVA
> 
>  Trading system written by:
>  Clyde Lee (FuturesMagic) Copyright (c) 1997
>  clydelee@xxxxxxx
> 
>  System LeePivotMOVA - System counts how many times in the past
>  NBar2Cnt bars (including current one) that High price has been
>  above the XAverage of length LengH of the average of the R1 AND R2
>  (resistance levels computed by pivot computation).  Time periods of
>  7 to 10 bars seem to work pretty good.
> 
>  System also counts how many times in this same period the Low price
>  has been below the XAverage of length LengL of the average of the
>  S1 AND S2 (support levels computed by pivot computation).
> 
>  When the number of high counts minus the low counts exceedes
>  or is equal to the value CntDiff then the system attempts to
>  buy the next day at the average of the R12 AND S12 average
>  values.  To sell the low count must have the same difference
>  over the high count.  A difference of 2 or 3 or 4 seems to be
>  ideal for most vehicles.
> 
>  An enddate of 999999 will cause system to close all positions
>  on last bar of file.  Don't set to this if running real life!!!
> 
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
> 
> }
> 
> inputs:     LengH(7),      {Length for Resistance XAverage}
>             LengL(10),     {Length for Support    XAverage}
>             NBar2Cnt(10),  {Number of bars to use in over/under count}
> 
>             CntDiff(3),    {Difference in over resistance and
>                               under support for a good trade}
>             BegDate(650101),EndDate(991231);
> 
> Vars:   UPCnt(0),DNCnt(0),RawCnt(0);
> Vars:   TPHigh(0),TPLow(0);
> 
> 
>  TPHigh=LeePivotR12Average(LengH);
>  TPLow =LeePivotS12Average(LengL);
>  If TPLow>TPHigh then TPLow=LeePivotS12Average(LengH);
>  RawCnt=RawCnt+1;
> 
> If Date>=BegDate and Date<EndDate and RawCnt>15 then begin
> 
>  Value2=(TPHigh+TPLow)*.5;
>  ExitLong  TPLOw   stop;
>  ExitShort TPHIgh  stop;
> 
>  UPCnt=0;DNCnt=0;
>  For Value1=0 to NBar2Cnt-1 Begin
>   If L[Value1]<=TPLow[Value1]  then DNCnt=DNCnt+1;
>   If H[Value1]>=TPHigh[Value1] then UPCnt=UPCnt+1;
>  End;
> 
>  Value3=UPCnt-DNCnt;
>  If Value3>=+CntDiff then buy  ("TPLong")  at Value2 stop;
>  If Value3<=-CntDiff then sell ("TPShort") at Value2 stop;
> 
> End;
> 
> If (LastBarOnChart=True and EndDate=999999) or  Date>=EndDate then
> begin
>  If marketposition =  1 then exitlong {("exl") at Market};
>  If marketposition = -1 then exitshort{("exs") at Market};
> End;
> 
> 
> END OF CODE FOR SYSTEM
> 
> 
> 
> 
>                   Name: Leepivot.ela
>    Part 1.2       Type: application/x-unknown-content-type-ELA_auto_file
>               Encoding: base64
> 
>                                  Name: vcard.vcf
>                Part 1.3          Type: text/x-vcard
>                              Encoding: 7bit
>                           Description: Card for Clyde Lee