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

ELA - Frequency & Amplitude Plot



PureBytes Links

Trading Reference Links

<x-html><HTML>
<TT>Several people asked me about the frequency and</TT>
<BR><TT>amplitude plots which were included in some postings</TT>
<BR><TT>of the SwingMachine output.</TT><TT></TT>

<P><TT>Following is a listing of an indicator which will</TT>
<BR><TT>provide this same information insofar as the frequency</TT>
<BR><TT>and the amplitude of waves within a given time window.</TT><TT></TT>

<P><TT>Because of limitations about maxbarsback in Omega</TT>
<BR><TT>software you can only analyze about 1/4 of a given set</TT>
<BR><TT>of data.&nbsp; If you want to evaluate as much of the data</TT>
<BR><TT>as possible then let the default inputs for begdate and</TT>
<BR><TT>enddate alone.</TT><TT></TT>

<P><TT>I have also attached a&nbsp;&nbsp; .gif&nbsp;&nbsp; file to show
how the</TT>
<BR><TT>results should look.&nbsp; Please note that by use of the</TT>
<BR><TT>"Data Window" and the "bar" cursor you can read the</TT>
<BR><TT>frequency (in time units of the underlying data -- days,</TT>
<BR><TT>weeks, months, 5min, ....) and the amplitude of the</TT>
<BR><TT>cycles which appear in the data over the date range</TT>
<BR><TT>specified.</TT><TT></TT>

<P><TT>Clyde Lee</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>{************************************************************</TT>
<BR><TT>The following is an indicator! }</TT><TT></TT>

<P><TT>Input: BegDate(650101),EndDate(991231);</TT>
<BR><TT>Var:&nbsp; init(0),pass(0),PKNT(0),begbar(0),endbar(0);</TT>
<BR><TT>{Array: Peaks[50](0),PBars[50](0);}</TT><TT></TT>

<P><TT>pass=pass+1;</TT>
<BR><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 {and currentbar&lt;700} and init=0 then begin</TT>
<BR><TT>&nbsp;Value4=endbar-begbar+1;{LengAnl;}</TT>
<BR><TT>&nbsp;If Value4>CurrentBar/2 then Value4=IntPortion(CurrentBar/2);</TT>
<BR><TT>&nbsp;For Value1=Value4 downto 3&nbsp; begin</TT>
<BR><TT>&nbsp; VALUE3 = fourline(c[currentbar-endbar],VALUE1,Value4,FALSE);</TT>
<BR><TT>&nbsp; PLOT3[currentbar-endbar+Value4-VALUE1](Value3,"Ampl");</TT>
<BR><TT>&nbsp; plot2[currentbar-endbar+Value4-Value1](value1,"Freq");</TT>
<BR><TT>{</TT>
<BR><TT>&nbsp; IF Value1>5 then begin</TT>
<BR><TT>&nbsp;&nbsp; if (Value9&lt;=Value8) and (Value8>=Value3) then&nbsp;
begin</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; PKNT=PKNT+1;Peaks[PKNT]=Value8;PBars[PKNT]=Value1-1;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp; print(init,pass,pknt,peaks[pknt],pbars[pknt]);</TT>
<BR><TT>&nbsp;&nbsp; end;</TT>
<BR><TT>&nbsp; end;</TT>
<BR><TT>&nbsp; Value9=Value8;Value8=VAlue3;</TT>
<BR><TT>}</TT>
<BR><TT>&nbsp;End;</TT>
<BR><TT>&nbsp;Init=1;</TT>
<BR><TT>END;</TT>
<BR><TT></TT>&nbsp;<TT></TT>

<P><TT>{************************************************************</TT>
<BR><TT>The following is a function! }</TT><TT></TT>

<P><TT>{</TT>
<BR><TT>SUB FOURLINE (PRICES!(), PERIOD!, TMIN, TMAX, PEAKA!, RADS!)</TT>
<BR><TT>above is original call from SwingMachine</TT><TT></TT>

<P><TT>Returns the amplitude or phase of the wave of specified period.</TT>
<BR><TT>Set input&nbsp; DOPHAS&nbsp; to a value of true to get phase angle.&nbsp;
A</TT>
<BR><TT>value of false will return the amplitude of selected wave.</TT><TT></TT>

<P><TT>Computation based on Singleton approximation -- veRRRRRRRRRy fast.</TT><TT></TT>

<P><TT>Amplitude units are same as input data.&nbsp; Phase is measured
in</TT>
<BR><TT>degrees.</TT><TT></TT>

<P><TT>}</TT>
<BR><TT>INPUTS:&nbsp; 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; TMIN(0),TMAX(0),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 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><TT></TT>

<P><TT>If DOPHAS THEN FOURLINE = DEGS ELSE FOURLINE=PEAKA;</TT>
<BR><TT></TT>&nbsp;</HTML>
</x-html>
Attachment Converted: "c:\eudora\attach\Freqampl.ela"

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

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