PureBytes Links
Trading Reference Links
|
Corey,
Thank you for sharing....
I notice at the bottom of the formula....you have a
Param() for RSI lookback Divisor....since it is not assigned, I do not believe
it serves any purpose at this time...is this correct ?
T=SmoothPeriod/Param<FONT
size=2>("SmoothPeriod
Divisor",<FONT color=#ff00ff
size=2>1,<FONT color=#ff00ff
size=2>1,<FONT color=#ff00ff
size=2>5,<FONT color=#ff00ff
size=2>0.1);
T2=T/4<FONT
size=2>;
Param("RSI Lookback
Divisor",<FONT color=#ff00ff
size=2>4,<FONT color=#ff00ff
size=2>1,<FONT color=#ff00ff
size=2>15,<FONT color=#ff00ff
size=2>0.1);// Not assigned
Anthony
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Corey
Saxe
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, February 08, 2004 5:03
PM
Subject: Re: [amibroker] Re: Determining
cycles
Anthony,
Here (attachment and below) is an example of RSI driven by
Hilbert cycle periods. As you can tell, I'm not done with this formula
either.
Note that the Hilbert transform part of the cycle period
formula is different. I have found that over time Ehlers has made different
versions. I collect them like beer bottles and test them for accuracy and
response... like beer.
-CS
/*
----------------------------------------------------------
Adaptive RSI w/Hilbert Cycle
Period
AFL conversion by Corey Saxe
<FONT color=#000000
size=2>----------------------------------------------------------
*/
SetBarsRequired(
100000, 0 );
Prices =(<FONT
color=#ff0000>H+<FONT
color=#ff0000>L)/<FONT
color=#4b0082>2;
Smoother = <FONT
color=#4b0082>0; Detrender = <FONT
color=#4b0082>0;
I1 = 0<FONT
size=2>; I2 = 0<FONT
size=2>;
Q1 = 0<FONT
size=2>; Q2 = 0<FONT
size=2>;
jI = 0<FONT
size=2>; jQ = 0<FONT
size=2>;
X1 = 0<FONT
size=2>; X2 = 0<FONT
size=2>;
Y1 = 0<FONT
size=2>; Y2 = 0<FONT
size=2>;
Re = 0<FONT
size=2>; Im = 0<FONT
size=2>;
Period = <FONT
color=#4b0082>0;SmoothPeriod=<FONT
color=#4b0082>1;
CU=0<FONT
size=2>; CD=0<FONT
size=2>;
pi = 4<FONT
size=2> * atan(<FONT
color=#4b0082>1) ;
for (i = 6;
i<BarCount; i++)
{
Smoother[i] = (<FONT
color=#4b0082>4*Prices[i] + <FONT
color=#4b0082>3*Prices[i-<FONT
color=#4b0082>1]+ <FONT
color=#4b0082>2*Prices[i-<FONT
color=#4b0082>2]+ Prices[i-<FONT
color=#4b0082>3])/<FONT
color=#4b0082>10;
Detrender[i] = (<FONT
color=#4b0082>0.0962*Smoother[i] + <FONT
color=#4b0082>0.5769*Smoother[i-<FONT
color=#4b0082>2] - <FONT
color=#4b0082>0.5769*Smoother[i-<FONT
color=#4b0082>4] - <FONT
color=#4b0082>0.0962*Smoother[i-<FONT
color=#4b0082>6]) * (<FONT
color=#4b0082>0.075*Period[i-<FONT
color=#4b0082>1] + <FONT
color=#4b0082>0.54<FONT
size=2>);
//{Compute InPhase AND Quadrature
components}
Q1[i] = (<FONT
color=#4b0082>0.0962*Detrender[i] + <FONT
color=#4b0082>0.5769*Detrender[i-<FONT
color=#4b0082>2] - <FONT
color=#4b0082>0.5769*Detrender[i-<FONT
color=#4b0082>4] - <FONT
color=#4b0082>0.0962*Detrender[i-<FONT
color=#4b0082>6])*(<FONT
color=#4b0082>0.075*Period[i-<FONT
color=#4b0082>1] + <FONT
color=#4b0082>0.54);
I1[i] = Detrender[i-<FONT
color=#4b0082>3<FONT
size=2>];
//{advance the phase of I1 AND Q1 by 90
degrees}
jI[i] = <FONT
color=#4b0082>0.0962*I1[i] + <FONT
color=#4b0082>0.5769*I1[i-<FONT
color=#4b0082>2] - <FONT
color=#4b0082>0.5769*I1[i-<FONT
color=#4b0082>4] - <FONT
color=#4b0082>0.0962*I1[i-<FONT
color=#4b0082>6] * (<FONT
color=#4b0082>0.075*Period[i-<FONT
color=#4b0082>1] + <FONT
color=#4b0082>0.54);
jQ[i] = <FONT
color=#4b0082>0.0962*Q1[i] + <FONT
color=#4b0082>0.5769*Q1[i-<FONT
color=#4b0082>2] - <FONT
color=#4b0082>0.5769*Q1[i-<FONT
color=#4b0082>4] - <FONT
color=#4b0082>0.0962*Q1[i-<FONT
color=#4b0082>6] * (<FONT
color=#4b0082>0.075*Period[i-<FONT
color=#4b0082>1] + <FONT
color=#4b0082>0.54<FONT
size=2>);
//{Phasor addition to equalize amplitude due
to quadrature calculations (AND 3 bar averaging)}<FONT
size=1>
I2[i] = I1[i] - jQ[i];
Q2[i] = Q1[i] + jI[i];<FONT
color=#008000 size=1>
//{Smooth the I AND Q components before
applying the discriminator}
I2[i] = <FONT
color=#4b0082>0.2*I2[i] + <FONT
color=#4b0082>0.8*I2[i-<FONT
color=#4b0082>1];
Q2[i] = <FONT
color=#4b0082>0.2*Q2[i] + <FONT
color=#4b0082>0.8*Q2[i-<FONT
color=#4b0082>1<FONT
size=2>];
//{Homodyne
Discriminator}
//{Complex Conjugate
Multiply}
X1[i] = I2[i]*I2[i-<FONT
color=#4b0082>1];
X2[i] = I2[i]*Q2[i-<FONT
color=#4b0082>1];
Y1[i] = Q2[i]*Q2[i-<FONT
color=#4b0082>1];
Y2[i] = Q2[i]*I2[i-<FONT
color=#4b0082>1];
Re[i] = X1[i] + Y1[i];
Im[i] = X2[i] - Y2[i];<FONT
color=#008000 size=1>
//{Smooth to remove undesired Cross
products}
Re[i] = <FONT
color=#4b0082>0.2*Re[i] + <FONT
color=#4b0082>0.8*Re[i-<FONT
color=#4b0082>1];
Im[i] = <FONT
color=#4b0082>0.2*Im[i] + <FONT
color=#4b0082>0.8*Im[i-<FONT
color=#4b0082>1<FONT
size=2>];
//{Compute Cycle
Period}
if<FONT
size=2> (Im[i] != 0
AND Re[i] != <FONT
color=#4b0082>0) Period[i] = (<FONT
color=#4b0082>2*pi)/<FONT
color=#b300b3>atan<FONT
size=2>(Im[i]/Re[i]);
if<FONT
size=2> (Period[i] > 1.5<FONT
size=2>*Period[i-1])
Period[i] = 1.5<FONT
size=2>*Period[i-1<FONT
size=2>];
if<FONT
size=2> (Period[i] < 0.67<FONT
size=2>*Period[i-1])
Period[i] = 0.67<FONT
size=2>*Period[i-1<FONT
size=2>];
if<FONT
size=2> (Period[i] < 6<FONT
size=2>) Period[i] = 6<FONT
size=1>;
if<FONT
size=2> (Period[i] > 50<FONT
size=2>) Period[i] = 50<FONT
size=1>;
Period[i] = <FONT
color=#4b0082>0.2*Period[i] + <FONT
color=#4b0082>0.8*Period[i-<FONT
color=#4b0082>1<FONT
size=2>];
//End Hilbert Cycle
Period-----------------------------------------------<FONT
size=1>
SmoothPeriod[i] = <FONT
color=#4b0082>0.33 * Period[i] + <FONT
color=#4b0082>0.67 * SmoothPeriod[i-<FONT
color=#4b0082>1];
}
/*
'x=int(0.5 * SmoothPeriod(i))
' for n = 1 To int(0.5 *
SmoothPeriod(i))
' if Close(n) > Close(n-1)
then
' CU(n) = CU(n-1) + ( Close(n) - Close(n-1)
)
' End if
'if Close(n) < Close(n-1) then
' CD(n) = CD(n-1) + ( Close(n-1) - Close(n)
)
'End if
'if (CU(n) + CD(n)) <> 0
then
' RSIh(n) = (100 * ( CU(n)) /( CU(n) + CD(n) )
)
' End if
'Next
*/
T=SmoothPeriod/<FONT
color=#b300b3>Param(<FONT
color=#0000ff>"SmoothPeriod Divisor",<FONT
color=#4b0082>1,<FONT
color=#4b0082>1,<FONT
color=#4b0082>5,<FONT
color=#4b0082>0.1);
T2=T/4<FONT
size=2>;Param(<FONT
color=#0000ff>"RSI Lookback Divisor",<FONT
color=#4b0082>4,<FONT
color=#4b0082>1,<FONT
color=#4b0082>15,<FONT
color=#4b0082>0.1);
mo = Prices-<FONT
color=#b300b3>Ref<FONT
size=2>(Prices,-T2);
Up = <FONT
color=#b300b3>IIf( mo><FONT
color=#4b0082>0, mo, <FONT
color=#4b0082>0);
Dn = <FONT
color=#b300b3>IIf( mo<<FONT
color=#4b0082>0, -mo, <FONT
color=#4b0082>0);
Ut = <FONT
color=#b300b3>AMA(Up,<FONT
color=#4b0082>2/(<FONT
color=#4b0082>2*T));
Dt = <FONT
color=#b300b3>AMA(Dn,<FONT
color=#4b0082>2/(<FONT
color=#4b0082>2*T));
RSIt=<FONT
color=#4b0082>100<FONT
size=2>*(Ut/(Ut+Dt));
GraphXSpace<FONT
size=2>=5;
Plot<FONT
size=2>(RSIt,"RSI-Hilbert",0,1);<FONT
face=Verdana color=#b300b3 size=1>
Plot<FONT
face=Verdana>(RSI<FONT
face=Verdana>(LastValue<FONT
face=Verdana>(Smoothperiod)),"LastValue
RSI",1<FONT
face=Verdana>,1<FONT face=Verdana
size=1>);
Plot(T,"Smoothed
Cycle Period",2,1|<FONT
face=Verdana>styleOwnScale);
UT=<FONT
color=#b300b3>Param(<FONT
color=#0000ff>"Threshold",<FONT
color=#4b0082>70,<FONT
color=#4b0082>50,<FONT
color=#4b0082>100,<FONT
color=#4b0082>1<FONT
size=2>);
PlotGrid<FONT
size=2>(UT,0);
PlotGrid<FONT
size=2>(100-UT,0);
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
Anthony
Faragasso
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, February 08, 2004 4:28
AM
Subject: Re: [amibroker] Re:
Determining cycles
Corey,
How do you use this formula with other
indicators....could you give us an example.....
Thank you
Anthony
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Corey
Saxe
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Sunday, February 08, 2004 6:24
AM
Subject: Re: [amibroker] Re:
Determining cycles
Chuck,
One of the things that I was working on is an improved
"smoother" (Smoother2) for the input data to the Hilbert transform (TASC
v18:11) rather that Ehlers smoother (Smoother1). As you can see I was
trying out Tillson's T3 smoother, and "Periods2" is just the amount of
periods of smoothing that T3 is using. "Smoother2" is the T3 output for
use in the rest of the formula. "a" is simply the "Hot" input parameter
for use in T3. Note that I am using TEMA and not EMA as the original T3
suggests. (BTW, I tripped over a TASC V19:6 article by Steve Burns that
describes an adaptive T3 to boot.)
Yes, I undestand that the formula should be able to
accurately find cycles down to a period of 6 days but using a quick
and dirty test using a synthetic waveform (Sine Wave Test in the formula),
I found odd fluctuations in cycle period output below 9 days. I am still
working on a resolution for it.
Smoother1 is the native smoother from Ehlers original
formula. Smoother2 is my replacement of it by T3.
The formula that I sent for Ara is just one of many
rough test examples, not yet ready for prime time. Ara and
everyone are free to twist and tweak it as they please. When I am
confident of the accuracy of its output (and the accuracy of my
translation and AFL coding), I would be happy to share.
Below is the EasyLanguage (Ha!) formula I derived from.
<FONT face=Arial
size=1>
{
—————————————————————————————
HilbertPeriod
(Function) by John Ehlers (7/22/00)
This is the
Hilbert Cycle Period Function used by the Hilbert Channel
Breakout
System.
<FONT face=Verdana color=#000080
size=2>————————————————————————————— }
Inputs:
Price(numeric);
Vars: Smoother(0),
Detrender(0), I1(0), Q1(0), jI(0), jQ(0),
I2(0),Q2(0),
X1(0), X2(0), Y1(0), Y2(0), Re(0), Im(0), Period(0);
If CurrentBar
>5 then begin
Smoother =
(4*Price + 3*Price[1] + 2*Price[2] + Price[3])/10;
Detrender =
(.25*Smoother + .75*Smoother[2] - .75*Smoother[4]
-
.25*Smoother[6])*(.046*Period[1] + .332);
{Compute InPhase
and Quadrature components}
Q1 =
(.25*Detrender + .75*Detrender[2] - .75*Detrender[4] -
<FONT face=Verdana color=#000080
size=2>.25*Detrender[6])*(.046*Period[1] + .332);
I1 =
Detrender[3];
{advance the phase
of I1 and Q1 by 90 degrees}
jI = .25*I1 +
.75*I1[2] - .75*I1[4] - .25*I1[6];
jQ = .25*Q1 +
.75*Q1[2] - .75*Q1[4] - .25*Q1[6];
{Phasor addition
to equalize amplitude due to quadrature calculations
(and 3 bar
averaging)}
I2 = I1 -
jQ;
Q2 = Q1 +
jI;
{Smooth the I and
Q components before applying the discriminator}
I2 = .15*I2 +
.85*I2[1];
Q2 = .15*Q2 +
.85*Q2[1];
{Homodyne
Discriminator}
{Complex Conjugate
Multiply}
X1 =
I2*I2[1];
X2 =
I2*Q2[1];
Y1 =
Q2*Q2[1];
Y2 =
Q2*I2[1];
Re = X1 +
Y1;
Im = X2 -
Y2;
{Smooth to remove
undesired cross products}
Re = .2*Re +
.8*Re[1];
Im = .2*Im +
.8*Im[1];
{Compute Cycle
Period}
If Im <> 0
and Re <> 0 then Period = 360/ArcTangent(Im/Re);
If Period >
1.5*Period[1] then Period = 1.5*Period[1];
If Period <
.67*Period[1] then Period = .67*Period[1];
If Period <6
then Period = 6;
If Period >50
then Period = 50;
Period = .2*Period
+ .8*Period[1];
{END CORE
CODE}
HilbertPeriod =
Period;
end;
-CS
----- Original Message -----
<BLOCKQUOTE dir=ltr
>
<DIV
>From:
<A title=chuck_rademacher@xxxxxxxxxx
href="">Chuck Rademacher
To: <A
title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Saturday, February 07, 2004
7:47 PM
Subject: RE: [amibroker] Re:
Determining cycles
<FONT face=Arial color=#0000ff
size=2>Thanks, Phsst.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>I am using Corey's code with great success and I was a bit
concerned about "future leak". I couldn't see where it was
happening and didn't really take the time to investigate. I
just liked the results I was getting.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>Corey, I'm hoping that you see this email as I have a couple of
questions for you.
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>1. Can you tell me what is going on with "Periods2" and
"a"? I see you have them as Param statements, but can you
recommend defaults. If I do understand what you are doing
with Periods2, your default of "5" seems a bit low.
Espeicially in light of your comment about "Periods < 9 are NOT
reliable". Or is that referring to some other
variable?
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>2. You seem to have built-in two smoothing techniques
(Smoother1 and Smoother2). Can you tell me more about the logic
behind these?
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>
<FONT face=Arial color=#0000ff
size=2>Thanks.
<BLOCKQUOTE
>
<FONT face="Times New Roman"
size=2>-----Original Message-----From: Phsst
[mailto:phsst@xxxxxxxxx]Sent: Saturday, February 07, 2004
10:00 PMTo: amibroker@xxxxxxxxxxxxxxxSubject:
[amibroker] Re: Determining cyclesChuck and
Corey,The offending line of code is:SetBarsRequired(
1000000, 1000000 );The above line caused the 'Check' feature
to issue a warning aboutreferencing 'future
quotes'.Regards,Phsst--- In
amibroker@xxxxxxxxxxxxxxx, "Chuck
Rademacher"<chuck_rademacher@x> wrote:>
Corey,> > When I used your code (or mine) for the
HilbertPeriod thingie, AB thinks> that we are looking into the
future. Any idea where to look for the>
problem?> -----Original
Message-----> From: Corey Saxe
[mailto:res1wgwl@xxxx]> Sent: Saturday, February
07, 2004 5:30 AM> To:
amibroker@xxxxxxxxxxxxxxx> Subject: Re: [amibroker]
Determining cycles> > > Ara,>
> I use dynamic periods for nearly everything. To
suppose that amarket is> always and forever going to cycle
at say, 21 days is absurd.> > Hence, why I
supported dynamic parameter input for variousfunctions and>
indicators.> > Something I've been tweaking
is included.> > Note that each indicator or
metric that you desire to measure hasits own> sweet-spot
which will be a multiple (or fraction) of the resulting cycle>
frequency.> For instance, If you want to use cycle
period input to the MACD,you may> find that it works best
if the input periods are multiplied by 0.67, but> maybe RSI
works best if the cycle periods are multiplied by 0.5.>
> Don't bother with FFT. The deficiencies are vast.
Dennis Meyers did a> series of articles a few years ago in
Futures mag, and describedmany of the> failures of FFT to
work on market prices because of the constantvariability>
of the current cycle periods.> >
-CS> ----- Original Message
-----> From: Ara
Kaloustian> To:
Ami-Main> Sent: Friday, February 06,
2004 11:43 AM> Subject: [amibroker]
Determining cycles> > >
Has anyone used cycle length determined dynamically and used to
set> parameters for each run?>
> I considered using Fast Fourier
Transform... am open to any other> suggestions>
> If it works one can produce
constantly optimzed system ...geting close> to the"holly
grail"> >
Thanks> Ara> >
> Send BUG REPORTS to
bugs@xxxx> Send SUGGESTIONS to
suggest@xxxx>
----------------------------------------->
Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx> (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)>
-------------------------------------------->
Check group FAQ at:> <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>
> > > Send BUG REPORTS to
bugs@xxxx> Send SUGGESTIONS to
suggest@xxxx>
----------------------------------------->
Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx> (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)>
-------------------------------------------->
Check group FAQ at:> <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html>
>
>
Yahoo! Groups
Sponsor>
ADVERTISEMENT> > > > >
>---------------------------------------------------------------------------->
Yahoo! Groups Links>
> a.. To visit your group
on the web, go to:> <A
href="">http://groups.yahoo.com/group/amibroker/>
> b.. To unsubscribe from
this group, send an email
to:>
amibroker-unsubscribe@xxxxxxxxxxxxxxx>
> c.. Your use of Yahoo!
Groups is subject to the Yahoo! Terms of>
Service.Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend
SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page:
<A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to
bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|