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

Re: Mesa / Cycles



PureBytes Links

Trading Reference Links

<x-html><HTML>
<BODY TEXT="#000000" BGCOLOR="#FFFFCC" LINK="#0000EE" VLINK="#00FF00" ALINK="#FF0000">
<TT>Traders,</TT><TT></TT>

<P><TT>I use cycles quite a bit in my trading.&nbsp; I'm attaching</TT>
<BR><TT>an&nbsp; .ela&nbsp; file which implements the basic ideas which</TT>
<BR><TT>are used in a number of ways in my work.</TT><TT></TT>

<P><TT>There are two indicators:</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; FourLine&nbsp;&nbsp; and&nbsp;&nbsp;&nbsp; FourPeriod.</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; Fourline plots the fourier spectral lines from
3 to 120</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; periods from data taken from the specified input
time zone.</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp; FourPeriod plots the length of the maximum peak
of the</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; fourier line over the selected range of periods.&nbsp;
This is</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; done for every nth days (n=1...m) in the data
set.</TT><TT></TT>

<P><TT>What follows is the actual&nbsp; EL&nbsp; code for those who do
not</TT>
<BR><TT>have TradeStation.</TT><TT></TT>

<P><TT>I hope it helps you evaluate "lenght of period" involved in</TT>
<BR><TT>functions that are length sensitive.</TT><TT></TT>

<P><TT>{</TT>
<BR><TT>&nbsp;Function:&nbsp; FourLine</TT><TT></TT>

<P><TT>&nbsp;Purpose:&nbsp; Calculate the Fourier amplitude and phase</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; values at a selected price over a given</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; period of time.</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>&nbsp;Author:&nbsp;&nbsp; Clyde Lee, SYTECH/Futuresmagic.</TT>
<BR><TT>&nbsp;Copyright:&nbsp; Clyde Lee, 1998.</TT><TT></TT>

<P><TT>&nbsp;This is a conversion of a ProfessionalBasic routine that</TT>
<BR><TT>&nbsp;is used in SwingMachine software to perform and display</TT>
<BR><TT>&nbsp;Fourier analyses and projections.</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>SUB FOURLINE (PRICES!(), PERIOD!, TMIN, TMAX, PEAKA!, RADS!)</TT><TT></TT>

<P><TT>Returns the amplitude OR phase of the wave of specified</TT>
<BR><TT>period in the form&nbsp;&nbsp; AAAAA.ppp</TT><TT></TT>

<P><TT>&nbsp;where:&nbsp;&nbsp;&nbsp; AAAAA = amplitude for wave in</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; same
units as input prices</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PPP = phase (in
radians).</TT><TT></TT>

<P><TT>Basic concepts from work of Singleton &amp; John Ehlers.&nbsp; Singleton</TT>
<BR><TT>first published the method in the late 1960's and Ehler has seen</TT>
<BR><TT>fit to use these methods in published works.</TT><TT></TT>

<P><TT>After conversion returns either amplitude or phase in degrees.</TT>
<BR><TT>Set input variable&nbsp; DoPhas&nbsp; to true to get phase data
or to</TT>
<BR><TT>false to get amplitude value.</TT><TT></TT>

<P><TT>}</TT>
<BR><TT>INPUTS: Price(numericseries),&nbsp; {Price on which to compute}</TT>
<BR><TT>&nbsp;&nbsp; Period(numericsimple),&nbsp; {Period of wave for analysis}</TT>
<BR><TT>&nbsp;&nbsp; NumBars(numericsimple),&nbsp; {number of bars to use
in computation}</TT>
<BR><TT>&nbsp;&nbsp; DoPhas(truefalse);&nbsp;&nbsp; {false=do ampl, true=do
phase}</TT><TT></TT>

<P><TT>VARS:&nbsp; PeakA(0),Degs(0);</TT>
<BR><TT>VARS:&nbsp; AF(0),XF(0),YF(0),GF(0),EF(0),</TT>
<BR><TT>&nbsp;&nbsp; Indx(0);</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp; AF = 360 / Period;</TT>
<BR><TT>&nbsp; XF = Cosine(AF); YF = Sine(AF);</TT>
<BR><TT>&nbsp; GF = 0; EF = Price[0];</TT><TT></TT>

<P><TT>&nbsp; FOR Indx = 1 to NumBars-1&nbsp; BEGIN</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; AF = EF;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; EF = AF * XF - GF * YF + Price[Indx];</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; GF = AF * YF + GF * XF;</TT>
<BR><TT>&nbsp; END;</TT>
<BR><TT>&nbsp; EF = (EF + EF) / NumBars; GF = (GF + GF) / NumBars;</TT>
<BR><TT>&nbsp; PeakA = SquareRoot(EF * EF + GF * GF);</TT><TT></TT>

<P><TT>&nbsp; IF EF=0 THEN Degs=0 ELSE Degs=Arctangent(GF/EF) ;</TT>
<BR><TT>&nbsp; IF GF>0 THEN VALUE1=1 ELSE VALUE1=-1;</TT>
<BR><TT>&nbsp; IF 0>EF THEN VALUE2=1 ELSE VALUE2=-1;</TT>
<BR><TT>&nbsp; Degs = Degs + (VALUE1 * VALUE2 * 180);</TT>
<BR><TT>&nbsp; WHILE Degs > 360&nbsp; BEGIN</TT>
<BR><TT>&nbsp;&nbsp; Degs = Degs - 360;</TT>
<BR><TT>&nbsp; END;</TT>
<BR><TT>&nbsp; WHILE Degs &lt; 0 BEGIN</TT>
<BR><TT>&nbsp;&nbsp; Degs = Degs + 360;</TT>
<BR><TT>&nbsp; END;</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>If DoPhas THEN FourLine = Degs</TT>
<BR><TT>ELSE&nbsp;&nbsp;&nbsp;&nbsp; FourLine=PeakA;</TT>
<BR><TT></TT>&nbsp;<TT></TT>

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

<P><TT>{</TT>
<BR><TT>&nbsp;Function:&nbsp; FourPeriod</TT><TT></TT>

<P><TT>&nbsp;Purpose:&nbsp; (1) Calculate the spectral lines beginning
with</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; the input&nbsp; BegPer&nbsp;&nbsp; and
ending with input&nbsp;&nbsp; EndPer</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; over a the closing price data set ending
with</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; the current close and extending back in
time for</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; a period equal to 4 times the analysis
being</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; performed.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; (2) Pick the largest peak value encountered</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; [note I said PEAK] in the range of periods
that</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; are specified for analysis and return
the period</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; value (period not amplitude) at which
this</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; maximum peak amplitude is found.</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>&nbsp;Author:&nbsp;&nbsp; Clyde Lee, SYTECH/Futuresmagic.</TT>
<BR><TT>&nbsp;Copyright:&nbsp; Clyde Lee, 1998.</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>

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

<P><TT>Input: BegPer (NumericSimple),</TT>
<BR><TT>&nbsp;&nbsp; EndPer (NumericSimple);</TT><TT></TT>

<P><TT>Var:&nbsp; BegAnl(EndPer*4);</TT><TT></TT>

<P><TT>If Currentbar>BegAnl then begin</TT>
<BR><TT>&nbsp;Value6=0;Value7=0;</TT>
<BR><TT>&nbsp;For Value1=EndPer downto BegPer&nbsp;&nbsp; begin</TT>
<BR><TT>&nbsp; VALUE3 = fourline(c,Value1,Value1*4,FALSE);</TT>
<BR><TT>&nbsp; {print (date,"v1..=",Value1,Value3,Value4,Value5,Value6,Value7);}</TT>
<BR><TT>&nbsp; If Value1&lt;EndPer-1 then begin</TT>
<BR><TT>&nbsp;&nbsp; if Value3&lt;=Value4 and Value4>=Value5 then begin</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; If Value4>Value6 then begin</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; Value6=Value4;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; Value7=Value1+1;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; End;</TT>
<BR><TT>&nbsp;&nbsp; end;</TT>
<BR><TT>&nbsp; End;</TT>
<BR><TT>&nbsp; Value5=Value4;Value4=Value3;</TT>
<BR><TT>&nbsp;End;</TT>
<BR><TT>&nbsp;FourPeriod = Value7;</TT>
<BR><TT>End</TT>
<BR><TT>Else FourPeriod = 0;</TT>
<BR><TT></TT>&nbsp;<TT></TT>

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

<P><TT>{</TT>
<BR><TT>&nbsp;Indicator:&nbsp; FourLine</TT><TT></TT>

<P><TT>&nbsp;Purpose:&nbsp; Plot a "line spectra" of the closing price
data</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; in the range&nbsp;&nbsp; BegDate&nbsp;&nbsp;&nbsp;
and&nbsp;&nbsp;&nbsp; EndDate.</TT><TT></TT>

<P><TT>&nbsp;&nbsp;&nbsp;&nbsp; Also plots a ramp indicating the frequency
of</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; each line.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; By activating the DataWindow&nbsp; and
setting it</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; to display one line of data (put at top
of chart)</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; then by clicking on a line showing a peak
you</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; can read the peak amplitude (*10) and
the period</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; of that peak.</TT><TT></TT>

<P><TT>&nbsp;Author:&nbsp;&nbsp; Clyde Lee, SYTECH/Futuresmagic.</TT>
<BR><TT>&nbsp;Copyright:&nbsp; Clyde Lee, 1998.</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>}</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>Input: BegDate(650101),EndDate(991231);</TT>
<BR><TT>Var:&nbsp; begbar(0),endbar(0);</TT><TT></TT>

<P><TT>if date&lt;=begdate then begbar=currentbar;</TT>
<BR><TT>if date&lt;=enddate then endbar=currentbar;</TT><TT></TT>

<P><TT>if LastBarOnChart=true then begin</TT>
<BR><TT>&nbsp;Value4=IntPortion((endbar-begbar)/4);&nbsp;&nbsp; {LengAnl;}</TT>
<BR><TT>&nbsp;if Value4>120 then Value4=120;</TT>
<BR><TT>&nbsp;For Value1 = Value4 downto 3&nbsp; begin</TT>
<BR><TT>&nbsp; VALUE3 = fourline(c[currentbar-endbar],VALUE1,Value1*4,FALSE);</TT>
<BR><TT>&nbsp; PLOT3[currentbar-endbar+Value4-VALUE1](Value3*10,"Ampl");</TT>
<BR><TT>&nbsp; plot2[currentbar-endbar+Value4-Value1](value1,"Freq");</TT>
<BR><TT>&nbsp;End;</TT>
<BR><TT>End;</TT><TT></TT>

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

<P><TT>{</TT>
<BR><TT>&nbsp;Indicatior:&nbsp; FourPeriod</TT>
<BR><TT>&nbsp;Purpose:&nbsp; Plot the PERIOD value at which the peak amplitude</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; spectral value was found in the periods
begper+1</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; to endper-1.</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; An interval (in number of bars) between
each of</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; these analysis can be specified to speed
up the</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; process.</TT><TT></TT>

<P><TT>&nbsp;Author:&nbsp;&nbsp; Clyde Lee, SYTECH/Futuresmagic.</TT>
<BR><TT>&nbsp;Copyright:&nbsp; Clyde Lee, 1998.</TT><TT></TT>

<P><TT>}</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>Input: BegPer(15),EndPer(25),Interval(5);</TT>
<BR><TT>Var:&nbsp; Begbar(0),endbar(0);</TT><TT></TT>

<P><TT>If Mod(Currentbar,Interval)=0 then begin</TT>
<BR><TT>&nbsp;Value3 = FourPeriod(BegPer,EndPer);</TT>
<BR><TT>&nbsp;PLOT3 (Value3,"PerL");</TT>
<BR><TT>END;</TT><TT></TT>

<P><TT>* * * * * * * * * * * * * * * * * * * * * * * * * * * *</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>Chris Jackson wrote:</TT>
<BLOCKQUOTE TYPE=CITE><TT>Snipped</TT><TT></TT>

<P><TT>&nbsp; What I've been doing is using an</TT>
<BR><TT>> easylanguage MRO function to find the highest high [20] and the
--</TT></BLOCKQUOTE>
<TT>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</TT>
<BR><TT>Clyde Lee&nbsp;&nbsp; Chairman/CEO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(Home of SwingMacine)</TT>
<BR><TT>SYTECH Corporation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
email:&nbsp;&nbsp; &lt;clydelee@xxxxxxx></TT>
<BR><TT>7910 Westglen, Suite 105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Work:&nbsp;&nbsp;&nbsp; (713) 783-9540</TT>
<BR><TT>Houston,&nbsp; TX&nbsp; 77063&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Fax:&nbsp;&nbsp;&nbsp;&nbsp; (713) 783-1092</TT>
<BR><TT>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</TT>
<BR><TT>&nbsp;</TT>
</BODY>
</HTML>
</x-html>
Attachment Converted: "c:\eudora\attach\Fourmisc.ela"

Attachment Converted: "c:\eudora\attach\FourMisc.gif"