Traders' Tips from TASC Magazine |
|
|
The Fourier indicator
In the Fourier Transform for Traders article, John F. Ehlers explains how to use Fourier transforms for measuring and estimating market cycles.
Tradecision's Indicator Builder enables you to create a custom indicator using the described method.
This indicator allows building only some of the price data spectrum components, defined by the parameter Peridq. The parameter Peridq is the component to be analyzed with the fluctuations for the indicated period. If the parameter ShowDC is true, Peridq is invalid, and the graph shows the behavior of the Dominant Cycle component, calculated automatically.
The following is the code for the Fourier custom indicator:
Input
Price :"Price" ,((H+L)/2);
Window:"Window",50;
ShowDC:"ShowDC",false;
Peridq:"Period",30,1,50;
end_input
var
alpha1:=0;
HP:=0;
CleanedData:=0;
Period:=0;
n:=0;
MaxPwr:=0;
Num:=0;
Denom:=0;
DominantCycle:=0;
array:CosinePart[50]:=0;
array:SinePart[50]:=0;
array:Pwr[50]:=0;
array:DB[50]:=0;
end_var
{Get a detrended version of the data by High Pass Filtering with
a 40 Period cutoff}
If HISTORYSIZE <= 5 Then Begin
HP := Price;
CleanedData := Price;
End; else Begin
alpha1 := (1 - Sin(360/40))/Cos(360/40);
HP := 0.5*(1 + alpha1)*(Price - Price\1\) + alpha1*HP\1\;
CleanedData := (HP + 2*HP\1\ + 3*HP\2\ + 3*HP\3\ + 2*HP\4\ + HP\5\)/12;
End;
{This is the DFT}
For Period := 8 to 50 do Begin
CosinePart[Period] := 0;
SinePart[Period] := 0;
For n := 0 to Window - 1 do Begin
CosinePart[Period] := CosinePart[Period] + CleanedData\n\*Cos(360*n/Period);
SinePart[Period] := SinePart[Period] + CleanedData\n\*Sin(360*n/Period);
End;
Pwr[Period] := CosinePart[Period]*CosinePart[Period] +
SinePart[Period]*SinePart[Period];
End;
{Find Maximum Power Level for Normalization}
MaxPwr := Pwr[8];
For Period := 8 to 50 do Begin
If Pwr[Period] > MaxPwr Then MaxPwr := Pwr[Period];
End;
{Normalize Power Levels and Convert to Decibels}
For Period := 8 to 50 do Begin
IF MaxPwr > 0 and Pwr[Period] > 0 Then DB[Period] := -
10* LogN(0.01 / (1 - 0.99*Pwr[Period] / MaxPwr))/LogN(10);
If DB[Period] > 20 then DB[Period] := 20;
End;
If ShowDC = True then Begin
{Find Dominant Cycle using CG algorithm}
Num := 0;Denom := 0;
For Period := 8 to 50 do Begin
Num := Num + Period*(3 - DB[Period]);
Denom := Denom + (3 - DB[Period]);
End;
End;
If Denom <> 0 then DominantCycle := Num/Denom;
this:=DominantCycle;
End;
Else this :=DB[Peridq];
return this;
|
Download to import into Tradecision. 
How to use this indicator in Tradecision:
- Click Download.
- Save this indicator in a safe location on your hard drive.
- Open Tradecision and in the Tools menu click Indicator Builder.
- In the Indicator Builder dialog, click Import, locate the saved file and then click OK.
The indicator will be added to the Custom Indicators list.
|
|
| |
| Sep 2007 |
|
| Aug 2007 |
|
| Jul 2007 |
|
| Jun 2007 |
|
| May 2007 |
|
| Apr 2007 |
|
| Mar 2007 |
|
| Feb 2007 |
|
| Jan 2007 |
|
| Dec 2006 |
|
| Nov 2006 |
|
| Oct 2006 |
|
| Sep 2006 |
|
| Aug 2006 |
|
| Jul 2006 |
|
| Jun 2006 |
|
| May 2006 |
|
| Apr 2006 |
|
| Mar 2006 |
|
| Feb 2006 |
|
| Jan 2006 |
|
| Mar 2005 |
|
| Mar 2005 |
|
| Feb 2005 |
|
| Feb 2005 |
|
| Dec 2004 |
|
| Nov 2004 |
|
| May 2004 |
|
| Dec 2003 |
|
| Oct 2003 |
|
| Jul 2003 |
|
| Apr 2003 |
|
| Mar 2003 |
|
| Mar 2003 |
|
| Feb 2003 |
|
| Jun 2001 |
|
| Jun 2001 |
|
| Jun 2001 |
|
| Jun 2001 |
|
| Jun 2001 |
|
| Apr 2001 |
|
| Feb 2001 |
|
| Aug 2000 |
|
| Aug 2000 |
|
| Feb 2000 |
|
| Jan 2000 |
|
| Sep 1999 |
|
| Sep 1999 |
|
|
|
|