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

[amibroker] Re: Cutting off volume spikes



PureBytes Links

Trading Reference Links




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> 
  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@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 Sponsor


  ADVERTISEMENT 












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.