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

[amibroker] Re: Hurst Channels



PureBytes Links

Trading Reference Links

With regards to d) ... I think you still missed my point about CMA's 
as I think what I did with the Hurst "LIKE" DE was to use what was 
straight out of chapter 7 of Millard ...

n = Overall CMA length 
n1 = The first CMA Length = n * 2 / 3
n2 = The second CMA Length = n * 1 / 3

As a result:

n1 = 2 * n2

This is just like what you describe in b) ...

The Trig ( or Cos and/or Sin ) fit of data is a different animal ... 
Because I knew I would be doing "sampling" of the CMA, I found the 
CMA part of this to be relatively unimportant ... I don't mean to 
imply that using one is a waste of time, it isn't but the exact 
configuration and length of it appears to be somewhat unimportant as 
it seems just having some form of smoothed data that doesn't lag is 
sufficent to drive the rest of the process.  When Cleeton's book 
catches up with you, you'll know where I'm coming from.

--- In amibroker@xxxxxxxxxxxxxxx, Andy Davidson <AndyDavidson@xxx> 
wrote:
>
> Fred,
> 
> Long post I'm afraid, but bear with me...
> 
> Since our last conversation I've been doing some head-scratching on 
> which method of CMA is best for extracting cycles. After re-reading 
> Millard and then trying to theorise my way in ever-decreasing 
circles 
> about what *should* be the best way, I decided to try to experiment 
and 
> find out what works best *in practice*. I've attached the results 
in the 
> form of plots and a summary spreadsheet for your (or anyone else's) 
> interest. Here's the logic behind the method (AFL code posted below 
for 
> sake of completeness) :
> 
> 1. I created two independant sine waves and a 'noise' component. 
These 
> individual components are plotted in the top pane.
> 2. I then added these together to create a composite 'price-like' 
plot - 
> plotted in grey in the bottom pane.
> 3. Four different kinds of Centred-MA (see below) were then plotted 
on 
> the bottom pane, with the composite as an input. The aim was to 
select a 
> periodicity for each CMA that would filter out the noise and the 
shorter 
> wavelength cycle (cycle 2), leaving the closest possible 
representation 
> of the longer cycle 1.
> 4. The lag, wavelength and amplitude of this CMA plot were then 
> *measured* (i.e. they weren't deduced theoretically, but were 
actual 
> observed values).
> 5. The values were compared on the spreadsheet.
> 
> The four different CMAs were based on:
> (a) Simple MA. The most basic centred SMA
> (b) Millard's "Smoothed Average" from Chapter 7...i.e. an MA of 
> n-periods which has been smoothed again by an MA of n/2 periods.
> (c) Triangular MA. This is an n/2 MA of an n/2 MA
> (d) Custom MA. This is per your last email with the first MA being 
> n*0.75 and the second being half that.
> 
> The Triangular MA has the same lag characteristics as a Simple MA. 
> However, in order to get the same *filtering* effect (i,e, to take 
out 
> cycle 2 completely) you have to near-enough double the periodity, 
which 
> then obviously takes the lag up. Experimenting seems to suggest 
that you 
> don't actually have to double it, which I guess is why I settled on 
a 
> multiplying factor of 1.5 for my Cycle Highlighter indicator. I 
think I 
> originally settled on 1.5 after mis-reading Millard's section on 
the 
> "Weighted MA" and have therefore been using something which was 
> nearly-correct but for the wrong reasons! Oh well, at least I have 
a 
> better idea now. However, the results of this seem to suggest that 
1.75 
> would be a better number, so I've changed my indicator accordingly. 
I'm 
> sure there's good theory behind why this should be so, but I can't 
think 
> it through. Can you?
> 
> So anyway, all that testing seems to show is that Millard's 
Smoothed 
> Average is the best for this purpose. My triangular MA seems to 
have 
> been suffering too much lag than necessary, for an output which 
also 
> suffers more damping. There seems to be nothing to choose between 
your 
> "Custom" CMA and the "Smoothed Average". This is obviously because 
they 
> are basically the same thing. Both are MAs smoothed by another MA 
half 
> the first's length. The fact that the "Smoothed Average" starts off 
with 
> and n-period MA and the "Custom" one starts with n-periods*0.75, 
just 
> means that the latter has to have "n" ramped up to provide the same 
> filtering/smoothing effect.
> 
> OK, so far so good. I've decided to ditch the Tri-CMA in favour of 
the 
> "Smoothed CMA". But here's another question. Millard states 
("Weighted 
> Average" section) that for those of us with computers(!!) it is 
> preferable to chose a centrally-weighted MA. Anyone know how to do 
that 
> without slowing things down even more? Is that the same as the 
geometric 
> mean?? My maths really is too rusty. The standard WMA function is 
no 
> good as it applies the maximum weighting to the *most recent* bar. 
We 
> would need, for example, in a 7-bar MA to have a weighting sequence 
of 
> 1-2-3-4-3-2-1
> 
> That'll do for now. Tomorrow's job is to add a third, longer, cycle 
and 
> see how extracting the middle cycle goes.
> 
> Cheers,
> Andy
> 
> 
> Fred wrote:
> >
> > You won't need the math texts to get though Hurst's course
> > material ... What you will need is time and patience ...
> >
> > The 2 / 3 factor is in essence I thought what you were advocating
> > i.e. the first cycle length being twice the second ...and the lag
> > being the combo of 1 less then half of both ... Millard suggests 
such
> > a methodology in chapter 7.
> >
> > The Hurst "Like" DE AFL I posted in the library was an interesting
> > project ... It seems however that the points could be better 
picked
> > then by using CMA's ... But that's another exercise ...
> >
> > --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%
40yahoogroups.com>, 
> > Andy Davidson <AndyDavidson@>
> > wrote:
> > >
> > > Don't worry Fred, straight talk is good for us all :-)
> > >
> > > I'll think about that 2/3 factor tomorrow - it's late here and 
my
> > brain
> > > is aching.
> > >
> > > I ordered the Cleeton book a while back but it still hasn't
> > arrived. I
> > > think it'll make for a nice relaxing Xmas read! I've got the 
book
> > by
> > > Hurst (Profit Magic), but I froze when I got to Appendix 6 and 
so I
> > > think I need Cleeton as you suggest! The Hurst course is on the
> > list as
> > > well, but first I think I'll have to get some old Maths texts 
out
> > of the
> > > attic and get the grey matter working again in that respect. My
> > maths is
> > > sadly lacking also and I feel it's really not adequate to take 
me
> > any
> > > further than I've got without some hard graft. Oh well, needs 
must
> > I
> > > suppose.
> > >
> > > As far as channels go, I had a look at your Hurst DE quickly 
today.
> > I
> > > played with Hurst-like channel trading myself a while back 
(when I
> > was
> > > still a naive Metastock user - yeah, I know, but it was OK for 
at
> > least
> > > that). I found that my skills were below that needed to tackle 
the
> > > extrapolation problem and so it was simply a matter of using
> > discretion
> > > and 'eyeballing' a la Hurst.
> > >
> > > That was when I found Millard's book and latched on to his Cycle
> > > Highlighter. To me it was (and still is) a simple and effective 
way
> > of
> > > determining the cycles if you have a bias towards discretionary
> > trading
> > > as I currently do. And by nature it is a normalised plot, so it
> > seemed
> > > logical to me to go about extrapolating on that plane before I
> > tried to
> > > tackle the price plot. However, I am now convinced (thanks in no
> > small
> > > part to yourself) that it is worth pursuing further with the
> > ultimate
> > > aim of automating the whole cycle-extraction process.
> > >
> > > So here's to the next step of the journey...hard graft and all.
> > >
> > >
> > > Fred wrote:
> > > >
> > > > Thanks for the description ... It wasn't a sarcastic comment 
per
> > > > se ... It is imho a benefit to be able to hear from authors of
> > code
> > > > what the process is that is going on as opposed to someone
> > > > unfamiliar with the code having to dig it out ...
> > > >
> > > > I agree with your comments in 1 & 2 ... I had initially
> > implemented
> > > > Millard's CMA in the Hurst DE I posted in the library this 
way ...
> > > >
> > > > Lag = int(Period / 2);
> > > > CMA = Ref(MA(MA(Data, Lag), Lag), Lag);
> > > >
> > > > It would seem though after reading Millard more carefully 
that a
> > > > better implementation is something like
> > > >
> > > > CMAL1 = Int(Period * 2 / 3);
> > > > if (CMAL1 < 5)
> > > > CMAL1 = 5;
> > > > If (CMAL1 % 2 == 0)
> > > > CMAL1 = CMAL1 + 1;
> > > > CMAL2 = Period - CMAL1;
> > > > If (CMAL2 % 2 == 0)
> > > > CMAL2 = CMAL2 + 1;
> > > > Lag = (CMAL1 - 1) / 2 + (CMAL2 - 1) / 2;
> > > >
> > > > CMA = Ref(MA(MA(Data, CMAL1), CMAL2), Lag)
> > > >
> > > > The only potential problem I see with this approach is it 
makes
> > the
> > > > minimum overall CMA Length 8.
> > > >
> > > > For the current AFL I implemented a simple CMA ... no muss /
> > > > fuss ... The reason is that the CMA would be sampled and
> > potentially
> > > > smoothed again ...
> > > >
> > > > I don't know whether or not you have Hurst's PM but he covers 
(
> > very
> > > > quickly ) the topic of pulling out the coeff's for multiple 
cycles
> > > > simultaneously in what is to me any way some rather complex 
math
> > in
> > > > Appendix 6 ... But then I'm hardly a math Wiz ... If you are
> > > > interested in this kind of thing I would strongly recommend
> > > > Cleeton's book which while out of print is still readily 
available
> > > > at Amazon and other places for a few bucks used. He discusses 
how
> > > > to perform a similar operation for one cycle and for multiple
> > cycles
> > > > simultaneously with one of the early steps being sampling of 
the
> > > > CMA ... He uses those points directly and as you can tell 
from my
> > > > description I opted for this approach more or less as well 
which
> > > > seems to produce some interesting results without requiring
> > Gaussian
> > > > Elimiation to solve multiple simultaneous equations.
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx 
> > <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%
> > 40yahoogroups.com>,
> > > > Andy Davidson <AndyDavidson@>
> > > > wrote:
> > > > >
> > > > > Hi Fred,
> > > > >
> > > > > It's good to be able to get back on this subject again,
> > especially
> > > > as it
> > > > > looks like there's a few of us who are 'into' cycles.
> > > > >
> > > > > Your work-in progress looks very interesting I must say. I
> > > > particularly
> > > > > like the idea in step 5 to reduce the data before finding a
> > > > > fit...brilliant in its simplicity. I also think your 
equation in
> > > > step 6
> > > > > will help me out...but without getting into that, here's the
> > > > general
> > > > > logic of my approach for comparison (and I take the 
sarcastic(?)
> > > > comment
> > > > > about explaining in English...I didn't do a good job of 
notating
> > > > the
> > > > > script properly!)
> > > > >
> > > > > 1. Calculate *two* CMAs using triangular-smoothed MAs. CMA1 
is
> > n-
> > > > periods
> > > > > length and CMA2 is n/2-periods. Both periods are rounded up 
to
> > the
> > > > > nearest odd number.
> > > > > 2. CMA1 allows wavelengths > n-periods to pass and filters 
out <
> > > > > n-period waves. CMA2 allows through all cycle wavelengths > 
n/2-
> > > > periods
> > > > > and filters out those < n/2. Therefore, subtracting CMA2 
from
> > CMA1
> > > > will
> > > > > give us the cycle (or combination of cycles if we're unlucky
> > > > enough, or
> > > > > have our value of n wrong) that lies between n/2 and n.
> > > > >
> > > > > Steps 1 and 2 are as per Millard's "Cycle Highlighter" (CH),
> > > > except he
> > > > > states that the best results are obtained with CMA1 being 
an SMA
> > > > and
> > > > > CMA2 being a Weighted MA. He also says CMA1 periods should 
be
> > > > *equal* to
> > > > > the wavelength to be isolated. This does work but, through
> > > > > experimenting, I have found that Triangular-MAs are best for
> > both
> > > > as
> > > > > they offer the superior smoothing-to-lag trade off. 
Furthermore,
> > > > the
> > > > > periodicity of CMA1 should be x1.5 the cycle you want 
(making
> > CMA2
> > > > > therefore x0.75). The logic still holds up and the results 
are
> > > > better
> > > > > IMO, with a more sine-like output.
> > > > >
> > > > > 3. Based on user-inputs (see below) I then generate an
> > artificial
> > > > sine
> > > > > wave. This is *anchored to the CH at its most recent (i.e.
> > > > confirmed)
> > > > > peak or trough*.
> > > > > 4. Correlation coefficients are calculated between (a) the 
sine
> > > > wave and
> > > > > the CH (or price - depending on user input) over 
the 'lookback'
> > > > period
> > > > > (see below) and (b) the sine wave and the price in the 'end
> > zone'
> > > > (i.e.
> > > > > the no-data zone for the CH at the right-hand edge).
> > > > >
> > > > > Inputs:
> > > > > "SINE WAVELENGTH" - this determines if the wavelength of the
> > sine
> > > > is (a)
> > > > > "as per the base cycle (CH)" (i.e. there is no attempt 
to 'fit'
> > > > the two
> > > > > curves beyond the anchor point) or (b) a "best fit". In the
> > second
> > > > case,
> > > > > the sine wavelength will depend on:
> > > > > "BEST FIT # RECENT CYCLES" - this is the number of full,
> > completed
> > > > > cycles of the CH where the correlation is measured. The 
start
> > > > point of
> > > > > X-cycles back is shown by a blue and red tick on the 
indicator.
> > If
> > > > > option (b) is chosen above the average wavelength of the CH 
is
> > > > measured
> > > > > in the zone from the blue tick to the end of its plot. This
> > value
> > > > is
> > > > > assigned to the sine plot. If option (a) above then we just 
get
> > X-
> > > > cycles
> > > > > back of both plots at the same periodicity.
> > > > >
> > > > > All the above is as per the first indicator I posted. The
> > > > following
> > > > > loops are done in the auto-fit version:
> > > > >
> > > > > 5. A loop from "Wavelength Min" to "Wavelength Max" is 
performed
> > > > to find
> > > > > the highest total correlation coefficient (a weighted 
average of
> > > > the
> > > > > 'CH/sine' and the 'sine/end-zone price' values).
> > > > > 6. The series of loops is repeated for "#Cycles Min" 
lookback up
> > > > to 5
> > > > > cycles lookback. I chose 5 as an arbitrary number...it's 
slow
> > > > enough as
> > > > > is and very rarely do you get a decent correlation going 
that
> > far
> > > > back.
> > > > > Obviously though when you do, you take notice.
> > > > >
> > > > > That's as much as I can tell you right now about the logic. 
Does
> > > > it
> > > > > work? Well, with the usual caveats blah-blah-blah, I would 
say
> > > > that it
> > > > > has been a very useful tool for me for a while now *in
> > conjunction
> > > > with
> > > > > other confirming and entry methods*
> > > > >
> > > > > Bear in mind that the purpose of the indicator is to find 
the
> > > > *clearest*
> > > > > cycle amongst those present, i.e. the one that conforms most
> > > > closely to
> > > > > a sine wave, and is therefore tradeable *on that time 
frame*. I
> > > > will
> > > > > manually switch between time-frames to get the various major
> > > > cycles
> > > > > (e.g. 1-hour, 4-hour, daily and weekly charts). Work 
on 'auto-
> > ing'
> > > > all
> > > > > that would be very processor intensive and requires further
> > > > thinking.
> > > > >
> > > > > The plot you sent seems to bear out a further truth about
> > trading
> > > > with
> > > > > cycles, one that I've experienced with this indicator more 
than
> > > > once:
> > > > > i.e. short-term cycles (measured in hours and a few days) 
are
> > less
> > > > > tradeable than longer-term ones (measured in a few days 
upwards
> > to
> > > > weeks
> > > > > & months). Certainly, in the plot you sent, most of the 
smoothed
> > > > price
> > > > > behaviour can be explained by the interaction of the two 
longest
> > > > > measured cycles (dark blue and cyan).
> > > > >
> > > > > Anyway, I look forward to ploughing through all the good 
stuff
> > > > you've
> > > > > already posted and hope you can help keep this thread going.
> > > > There's
> > > > > lots of really cool stuff going on here.
> > > > >
> > > > > Cheers for now,
> > > > > Andy
> > > > >
> > > > >
> > > > > Fred Tonetti wrote:
> > > > > >
> > > > > > Andy,
> > > > > >
> > > > > >
> > > > > >
> > > > > > Can you describe in English what your AFL does ? ...
> > > > > >
> > > > > >
> > > > > >
> > > > > > I've been playing with a Trig Fit a la Claud Cleeton the 
steps
> > > > for
> > > > > > which I would describe as follows ...
> > > > > >
> > > > > >
> > > > > >
> > > > > > 1. Optional - Normalize the input i.e. Data = log10((H + 
L) /
> > 2)
> > > > > >
> > > > > > 2. Calc an arbitrary length ( Parameterized but 11 at the
> > > > moment )
> > > > > > centered moving average ( CMA ) of the data
> > > > > >
> > > > > > 3. Calc a 1st order least squares fit ( LSF ) of the CMA 
over
> > > > the
> > > > > > period desired ( from / to range marker )
> > > > > >
> > > > > > 4. Subtract the LSF points from the data points resulting 
in
> > > > detrended
> > > > > > data.
> > > > > >
> > > > > > 5. Take an n-bar sampling of the detrended data. This 
array
> > > > with
> > > > > > "holes" or "gaps" in it needs either to be compressed or 
have
> > > > the
> > > > > > "gaps" filled ... I elected ( for the moment ) to calc a 
cubic
> > > > spline
> > > > > > to fill the gaps ( interpolation ) ...
> > > > > >
> > > > > > 6. Calc a LSF of the detrended data resulting in the 
coeffs
> > for
> > > > the
> > > > > > Trig equation Y = A Cos wX + B * Sin wX
> > > > > >
> > > > > > 7. Calc the correlation of the resulting sin wave to the
> > > > original
> > > > > > detrended data.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Repeat steps 5 & 6 varying n from 1 to ? looking for n 
where
> > the
> > > > > > correlation is the highest. This should yield the 
equation or
> > > > data
> > > > > > points that most closely correlate to the detrended data.
> > > > > >
> > > > > >
> > > > > >
> > > > > > 8. Subtract the points in the sin wave from the detrended 
data
> > > > > > resulting in a modified detrended data.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Repeat steps 5 - 8 looking for the next most significant
> > cycle.
> > > > This
> > > > > > can be done repeatedly until overall correlation stops 
getting
> > > > better
> > > > > > and usually results in 2 - 6 cycles ...
> > > > > >
> > > > > >
> > > > > >
> > > > > > See attached ...
> > > > > >
> > > > > >
> > > > > >
> > > > > > The white line in the upper graph is detrended price ...
> > > > > >
> > > > > > The alternating green / red line is the trig fit, in 
sample up
> > > > to the
> > > > > > vertical line and out of sample projection afterwards ...
> > > > > >
> > > > > > The lines in the bottom section are the individual cycles
> > found
> > > > in the
> > > > > > data.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Sometimes the projections are almost clairvoyant ... run 
time
> > > > however
> > > > > > is anything but quick ...
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > ----------------------------------------------------------
> > > > -------
> > > > > > I am using the free version of SPAMfighter for private 
users.
> > > > > > It has removed 8649 spam emails to date.
> > > > > > Paying users do not have this message in their emails.
> > > > > > Try SPAMfighter <http://www.spamfighter.com/go.asp?t=249 
> > <http://www.spamfighter.com/go.asp?t=249>
> > > > <http://www.spamfighter.com/go.asp?t=249 
> > <http://www.spamfighter.com/go.asp?t=249>>> for
> > > > free now!
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>




Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.27/517 - Release Date: 11/3/2006