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

Re: [amibroker] Re: Hurst Channels



PureBytes Links

Trading Reference Links

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