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. 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 .gif file to show
how the</TT>
<BR><TT>results should look. 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>
<BR><TT></TT> <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: 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<=begdate then begbar=currentbar;</TT>
<BR><TT>if date<=enddate then endbar=currentbar;</TT><TT></TT>
<P><TT>if LastBarOnChart=true {and currentbar<700} and init=0 then begin</TT>
<BR><TT> Value4=endbar-begbar+1;{LengAnl;}</TT>
<BR><TT> If Value4>CurrentBar/2 then Value4=IntPortion(CurrentBar/2);</TT>
<BR><TT> For Value1=Value4 downto 3 begin</TT>
<BR><TT> VALUE3 = fourline(c[currentbar-endbar],VALUE1,Value4,FALSE);</TT>
<BR><TT> PLOT3[currentbar-endbar+Value4-VALUE1](Value3,"Ampl");</TT>
<BR><TT> plot2[currentbar-endbar+Value4-Value1](value1,"Freq");</TT>
<BR><TT>{</TT>
<BR><TT> IF Value1>5 then begin</TT>
<BR><TT> if (Value9<=Value8) and (Value8>=Value3) then
begin</TT>
<BR><TT> PKNT=PKNT+1;Peaks[PKNT]=Value8;PBars[PKNT]=Value1-1;</TT>
<BR><TT> print(init,pass,pknt,peaks[pknt],pbars[pknt]);</TT>
<BR><TT> end;</TT>
<BR><TT> end;</TT>
<BR><TT> Value9=Value8;Value8=VAlue3;</TT>
<BR><TT>}</TT>
<BR><TT> End;</TT>
<BR><TT> Init=1;</TT>
<BR><TT>END;</TT>
<BR><TT></TT> <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 DOPHAS to a value of true to get phase angle.
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. Phase is measured
in</TT>
<BR><TT>degrees.</TT><TT></TT>
<P><TT>}</TT>
<BR><TT>INPUTS: PRICE(numericseries), {price on which to compute}</TT>
<BR><TT> PERIOD(numericsimple), {period of wave for analysis}</TT>
<BR><TT> NUMBARS(numericsimple), {number of bars to use
in computation}</TT>
<BR><TT> DOPHAS(truefalse); {false=do ampl, true=do
phase}</TT><TT></TT>
<P><TT>VARS: TMIN(0),TMAX(0),PEAKA(0),DEGS(0);</TT>
<BR><TT>VARS: AF(0),XF(0),YF(0),GF(0),EF(0),</TT>
<BR><TT> INDX(0);</TT>
<BR><TT> </TT>
<BR><TT> AF = 360 / PERIOD;</TT>
<BR><TT> XF = Cosine(AF); YF = Sine(AF);</TT>
<BR><TT> GF = 0; EF = PRICE[0];</TT><TT></TT>
<P><TT> FOR INDX = 1 TO NUMBARS-1 BEGIN</TT>
<BR><TT> AF = EF;</TT>
<BR><TT> EF = AF * XF - GF * YF + PRICE[INDX];</TT>
<BR><TT> GF = AF * YF + GF * XF;</TT>
<BR><TT> END;</TT>
<BR><TT> EF = (EF + EF) / NUMBARS; GF = (GF + GF) / NUMBARS;</TT>
<BR><TT> PEAKA = SquareRoot(EF * EF + GF * GF);</TT><TT></TT>
<P><TT> IF EF=0 THEN DEGS=0 ELSE DEGS=Arctangent(GF/EF) ;</TT>
<BR><TT> IF GF>0 THEN VALUE1=1 ELSE VALUE1=-1;</TT>
<BR><TT> IF 0>EF THEN VALUE2=1 ELSE VALUE2=-1;</TT>
<BR><TT> DEGS = DEGS + (VALUE1 * VALUE2 * 180);</TT>
<BR><TT> WHILE DEGS > 360 BEGIN</TT>
<BR><TT> DEGS = DEGS - 360;</TT>
<BR><TT> END;</TT>
<BR><TT> WHILE DEGS < 0 BEGIN</TT>
<BR><TT> DEGS = DEGS + 360;</TT>
<BR><TT> END;</TT><TT></TT>
<P><TT>If DOPHAS THEN FOURLINE = DEGS ELSE FOURLINE=PEAKA;</TT>
<BR><TT></TT> </HTML>
</x-html>
Attachment Converted: "c:\eudora\attach\Freqampl.ela"
Attachment Converted: "c:\eudora\attach\freqampl.gif"
Attachment Converted: "c:\eudora\attach\vcard126.vcf"
|