Trading Strategies Based On Digital Filters - page 73

 

Frequency bands

MadCow:
Simba,

Since any cyclical components in the final (say H1) signal must have been in the original M1 signal, but with a better signal to noise ratio, it seems to me that one should use the M1 signal to extract cyclical components. Of course the problem with this is that those components that are at say 20 hour periods will be very hard to extract from M1 data because the M1 period will require 60 times as many samples at M1. On the other hand, there may be many components that are at high frequencies in the M1 series, that alias into the H1 series several times causing more peaks than are really there.

The only simple way to investigate this is to look at the spectrum of an M1 signal and an H1 signal over the same (absolute) period, e.g. 200 hours or so. This cannot be done with the R_MESA tools currently available because the length required at M1 exceeds the capability of the algorithm as coded.

MadCow...

Madcow,

Yes to both,one should use the M1 signal and compare it with the H1,M5,15,M30..over the same absolute period...that is exactly what I did(starting by M5) and showed on the pics ...I scanned 540 h1 bars in h1,m30(1080 m30 bars),m15,m5...for the same range of absolute H1frequencies 1/90 to 1/180..so,I looked for cycles with periodicity 90 to 180 H1 periods(180 to 360 m30 periods,etc,etc)..and I found the same 2 cycles at all timeframes.

If I redo the scan to look for cycles 8 to 80 h1 periods,over an absolute span of 240 h1 bars,what I will find is a very different picture,everytimeframe is giving me back a different number of cycles,periods,amplitudes and phases...it is an untradable mess as you can see in the pic...So,using the right frequency bands,the ones that give you back clear cycles is one of the keys of working with cycles...to do so,you need a scanner that can scan at least 7k -9k m1 bars and give you back cyclic periods of up to 2k -3k m1 bars.

Fractal cycles...Basically:The number of iterations or passing of time before a fractal repeats(caveat emptor:It can repeat at the same OR at a different timeframe)....the vertical lines in the pic mark the later iterations of a fractal,fractal cycle is 22 or 23 bars(it is fractal )..BTW,at the close of Friday we completed a fractal iteration...I am extremely intrigued by today`s opening directional move for the next 22 bars.

http://www.elliottfractals.com/triggers/

Lammert Nonstochastic Saturation Macroeconomics: July 2005 Nonstochastic Saturation Macroeconomics - A New Science

Regards

S

Files:
campc24.gif  66 kb
 
MadCow:
Simba,

I've read Lammert's stuff, and so far I can't make heads or tails of it. Seems a lot like astrology, but a lot of people believe him apparently, so I must dig deeper. He appears to use the definition of fractal used in the MT4 "fractal.mq4", essentially extrema. How does that relate to fractal cycles?

But let me begin to prove myself useful:

1. Do not use the higher TF price series when looking for cyclic components. They will be noisier than M1. You appear to be doing this already... how about the rest of the forum?

2. Use an anti-aliasing filter on M1 data and sub-sample it's output to reduce computational complexity when searching for cyclical components of long periodicity. Match the aa filter to the frequencies you search for.

3. Do not "end point flatten" the price series when applying the FFT or Geortzel.

The first two items I have discussed above.

Consider the third. One can show that the periodogram is the maximum likelihood detector of a sinusoid in stationary white gaussian noise. I know that FX noise is not stationary, white or even Gaussian, but there is still an argument that the periodogram is a good thing to use. The periodogram is essentially the square of the Fourier transform of the signal, and suffers from the fact that it's variance does not decrease as the length of the sequence processed increases. When it is used to estimate spectral density, the data is windowed to reduce this "end point" effect. But we are interested in detecting the component, not in estimating the spectrum. If we were to use a set of bandpass filters to find the signal, we would not first endpoint flatten the price series. That would clearly be counterproductive, since it would decrease the weight of the most recent samples. So don't end point flatten the price series before applying the FFT or Geortzel.

4. The FFT or Geortzel are equivalent when adjusted for resolution. The Geortzel is more efficient when searching over a small set of frequencies. Use these interchangably depending on computational efficiency determined by the band being searched and the required resolution.

5. The MESA is good to estimate the spectrum, and in some cases (particularly for time varying sinusoids) may be better than the FFT. However, estimating the spectrum and detecting sinusoids are different tasks, and if the sinusoid lasts for the duration of the FFT, MESA is no better than the FFT in the maximum likelihood sense, and most probably not as good. So use the FFT and match it's resolution to the expected duration of the sinusoid. Forget the MESA, in spite of RC's excellent software.

These are only my opinions, but they can be backed mathematically if the model is simplified as stated. I also know that not everyone will agree, and that RC and Ehlers would particularly disagree, but I'm only trying to be useful as requested.

Regards ...MadCow...

I don`t know about the rest of the Forum,a few of them may be doing some interesting things,others will probably wait to be spoon fed.

Regards

S

 

Simba,

I've read Lammert's stuff, and so far I can't make heads or tails of it. Seems a lot like astrology, but a lot of people believe him apparently, so I must dig deeper. He appears to use the definition of fractal used in the MT4 "fractal.mq4", essentially extrema. How does that relate to fractal cycles?

Regards ...MadCow...

 

Variable length Goertzel

I want to apologize for abruptly editing my previous post. (You can read it in entirety in Simba'a reply). My reason was that I had discovered that end point flattening was not what I thought. It merely sets the two end points to 0 and adds a small amount to each sample between to compensate for this. It essentially adds a very long period component, that we can ignore. It does not distort the current output for sufficiently high frequency. Also I was misspelling Goertzel.

And I no longer feel that the FFT or Goertzel is the best way to find cyclic components.

In looking at end point flattening and the Goertzel algorithm I found that there may be a better way to find the spectral content when our goal is to use the estimated spectrum to predict the next few samples. We might want to use variable length Goertzel filters instead of the fixed length filters in all the Goertzel implementations. The attached picture shows the difference betwen the fixed length Goertzel implemented as Goertzel_v1.mq4 and a variable length Goertzel. Quite a difference.

I have a habit of writing notes to myself as I analyze a problem. As I grow older, I find that this helps with short term recall problems, which plague me (hence MadCow...). The attached document is my set of notes on the variable length Goertzel, and why I prefer it. I would appreciate any feedback.variable_length_goertzel_filters.doc

Regards ...MadCow...

 

Feedback

MadCow:
I want to apologize for abruptly editing my previous post. (You can read it in entirety in Simba'a reply). My reason was that I had discovered that end point flattening was not what I thought. It merely sets the two end points to 0 and adds a small amount to each sample between to compensate for this. It essentially adds a very long period component, that we can ignore. It does not distort the current output for sufficiently high frequency. Also I was misspelling Goertzel.

And I no longer feel that the FFT or Goertzel is the best way to find cyclic components.

In looking at end point flattening and the Goertzel algorithm I found that there may be a better way to find the spectral content when our goal is to use the estimated spectrum to predict the next few samples. We might want to use variable length Goertzel filters instead of the fixed length filters in all the Goertzel implementations. The attached picture shows the difference betwen the fixed length Goertzel implemented as Goertzel_v1.mq4 and a variable length Goertzel. Quite a difference.

I have a habit of writing notes to myself as I analyze a problem. As I grow older, I find that this helps with short term recall problems, which plague me (hence MadCow...). The attached document is my set of notes on the variable length Goertzel, and why I prefer it. I would appreciate any feedback.variable_length_goertzel_filters.doc

Regards ...MadCow...

MadCow,

As I see it from your .doc

1-The basis of all your thinking is that Goertzel needs 3*max period sample rates,so,if you want to scan for cycles up to 200 periods,you need at least 600 samples...Right.

2-Consequently,the low periodicity cycles(high freq) may not be representative of what really is happening at the moment...example,a 13 bars cycle found over a span of the last 600 bars may not be there now,and ,yes you are absolutely right.

3-Conceptually,there may be a simpler solution though,and that is just to scan separately for several frequency bands...so if you want to confirm the 13 periods cycle you found,you have to redo a scan over the last 39 bars..or,even better,do a scan over the last 60 bars for cycles with freqs 1/10 to 1/5.

Conclusion..you need to do different scans..this was hinted by JM Hurst in his 1600 page course,and explained by Brian Millard in detail....or,you can build a multifreq,multispan scanner that scans in "blocks" of related "max period vs length of scan"...that will be really original and innovative

Regards

S

 
SIMBA:
MadCow,

As I see it from your .doc

1-The basis of all your thinking is that Goertzel needs 3*max period sample rates,so,if you want to scan for cycles up to 200 periods,you need at least 600 samples...Right.

2-Consequently,the low periodicity cycles(high freq) may not be representative of what really is happening at the moment...example,a 13 bars cycle found over a span of the last 600 bars may not be there now,and ,yes you are absolutely right.

3-Conceptually,there may be a simpler solution though,and that is just to scan separately for several frequency bands...so if you want to confirm the 13 periods cycle you found,you have to redo a scan over the last 39 bars..or,even better,do a scan over the last 60 bars for cycles with freqs 1/10 to 1/5.

Conclusion..you need to do different scans..this was hinted by JM Hurst in his 1600 page course,and explained by Brian Millard in detail....or,you can build a multifreq,multispan scanner that scans in "blocks" of related "max period vs length of scan"...that will be really original and innovative

Regards

S

Clearly you're way ahead of me on this. It is nice to have confirmation that I can still think logically.

I looked at the use of different scans, and decided that trying to find short cycles in long blocks might miss them, so I might never go back to confirm that they were there. Also it would take a lot of extra computation to look at many blocks. So I looked at the code and decided that I could modify the Goertzel_v1 code to do the multifreq, multispan scanner directly. The code actually is simpler and takes fewer computation cycles than the original _v1. Innovation, or just luck? The modified Goertzel_v1 (now _v2) was used in my previous post.

Attached are two modifications, _v2 does the job without end point flattening, though it can be added by removing some comments in the code. _v3 does the whole job including end point flattening for each block/period. You can vary the minimum number of cycles to look for using the numcycles variable. This changes the resolution of the filters, with more cycles giving better resolution, but requiring more samples, so allowing for past signals to interfere with current signals. You also can use the median price instead of the close by setting the useclose to false. It does not make any difference that I can see.

My coding skills are pretty rusty, so there may be a coding problem with the end point flattening, but I think not. If there's no code problem, then EPF does not help for multi freq scanning.

The next few steps I will take are to decide how to select the components to use for prediction, and how to estimate the longevity of the prediction. I am inclined to use a measure of the SNR in each filter holding a peak to select peaks, rather than just the amplitude, but I have as yet no clue about prediction longevity.. perhaps experimentation will help. Any suggestions?

Regards ... MadCow...

goertzel_v3.mq4[/ATTACH]

Files:
 

Suggestions

MadCow:
Clearly you're way ahead of me on this. It is nice to have confirmation that I can still think logically.

I looked at the use of different scans, and decided that trying to find short cycles in long blocks might miss them, so I might never go back to confirm that they were there. Also it would take a lot of extra computation to look at many blocks. So I looked at the code and decided that I could modify the Goertzel_v1 code to do the multifreq, multispan scanner directly. The code actually is simpler and takes fewer computation cycles than the original _v1. Innovation, or just luck? The modified Goertzel_v1 (now _v2) was used in my previous post.

Attached are two modifications, _v2 does the job without end point flattening, though it can be added by removing some comments in the code. _v3 does the whole job including end point flattening for each block/period. You can vary the minimum number of cycles to look for using the numcycles variable. This changes the resolution of the filters, with more cycles giving better resolution, but requiring more samples, so allowing for past signals to interfere with current signals. You also can use the median price instead of the close by setting the useclose to false. It does not make any difference that I can see.

My coding skills are pretty rusty, so there may be a coding problem with the end point flattening, but I think not. If there's no code problem, then EPF does not help for multi freq scanning.

The next few steps I will take are to decide how to select the components to use for prediction, and how to estimate the longevity of the prediction. I am inclined to use a measure of the SNR in each filter holding a peak to select peaks, rather than just the amplitude, but I have as yet no clue about prediction longevity.. perhaps experimentation will help. Any suggestions?

Regards ... MadCow...

goertzel_v3.mq4[/ATTACH]

MadCow,

1-How to decide which components to take for prediction:Use 3 of your v3, set each one of them to (MaxPer-MinPeriod):50-10,100-50,200-100.

2-Then select just one cycle per v3,the one with the highest amplitude.

3-Then using,periodicity,amplitude and phase of each one of the 3 cycles,add them into a composite.

4-Length of prediction?..Besides computing the Lyapunov exponent ? rule of thumb,IMO,is to use one third to half the bars of the shortest cycle ..

Now,You may want to believe me or not,and,sincerely,you don`t have any reason,because I won`t explain why,besides telling you that I have been there and done that...

5-SNR:Forget about it..It doesn`t work,you can try as many ways as you want..they don`t work for selecting good cycles.

6-Using ALL the cycles?...;)..Try it and you will start believing me..IT DOESN`T WORK...prediction length will be less than 1 bar.

7-Using 3 cycles,but just the highest amplitude ones from 10-200?It can work,usually doesn`t,you will end up losing all the short periodicity cycles .

8-You want to use many cycles?It doesn`t work,but it can work if you use squared amplitudes,in any case ,don`t use more than 8 cycles.

Now..the best counsel I can give you..By far,the best way to TRADE(not predict) these cycles is to do as I wrote in number 1 and 2 and then...

9- Just trade on 3 cycles alignment(forget about composites)..I use phases in degrees not in radians,so when the 3 cycles align above 180 degrees,you can expect an upmove,when they align between 0 and 179 degrees you can expect a downmove...in practice,the rule I use is above 180 and below 270(for longs)..and above 0 and below 90(for shorts)...then,once you have the alignment,wait for price confirmation,specially trendline breakouts,before entering the trade,use a target related to the ATR of the timeframe you are trading and use a stop below previous low/above previous high...if the TP is >than the SL then take the trade,if it is not,then pass....Oh,and a small detail,always trade in the direction of the larger timeframe

Regards

S

 

Link about Hurst

Interesting Link... http://wintrend.com/Reports/TCPToday.pdf

By the way..October 16th is the turn date for sp500,then November 2nd and then,DA TOP..Between November 13th and December 9th(sorry,exact dat jut for charities )..yes,yes,the guy in the report says differently,but either him or myself is wrong...guess whom?..hahahhahah..check October 16th when it comes and decide.

S

 
SIMBA:
MadCow,

1-How to decide which components to take for prediction:Use 3 of your v3, set each one of them to (MaxPer-MinPeriod):50-10,100-50,200-100.

2-Then select just one cycle per v3,the one with the highest amplitude.

3-Then using,periodicity,amplitude and phase of each one of the 3 cycles,add them into a composite.

4-Length of prediction?..Besides computing the Lyapunov exponent ? rule of thumb,IMO,is to use one third to half the bars of the shortest cycle ..

Now,You may want to believe me or not,and,sincerely,you don`t have any reason,because I won`t explain why,besides telling you that I have been there and done that...

5-SNR:Forget about it..It doesn`t work,you can try as many ways as you want..they don`t work for selecting good cycles.

6-Using ALL the cycles?...;)..Try it and you will start believing me..IT DOESN`T WORK...prediction length will be less than 1 bar.

7-Using 3 cycles,but just the highest amplitude ones from 10-200?It can work,usually doesn`t,you will end up losing all the short periodicity cycles .

8-You want to use many cycles?It doesn`t work,but it can work if you use squared amplitudes,in any case ,don`t use more than 8 cycles.

Now..the best counsel I can give you..By far,the best way to TRADE(not predict) these cycles is to do as I wrote in number 1 and 2 and then...

9- Just trade on 3 cycles alignment(forget about composites)..I use phases in degrees not in radians,so when the 3 cycles align above 180 degrees,you can expect an upmove,when they align between 0 and 179 degrees you can expect a downmove...in practice,the rule I use is above 180 and below 270(for longs)..and above 0 and below 90(for shorts)...then,once you have the alignment,wait for price confirmation,specially trendline breakouts,before entering the trade,use a target related to the ATR of the timeframe you are trading and use a stop below previous low/above previous high...if the TP is >than the SL then take the trade,if it is not,then pass....Oh,and a small detail,always trade in the direction of the larger timeframe

Regards

S

Simba..

Thank you for your generosity. I think you have saved me many days of fruitless search. I will use the information as well as I can.

There are a couple of things that I should explain to the forum in case anyone wishes to use _v2 or _v3.

First, the phase computation seems to be in contradiction to the MT4 definition of the MathArctan function. I have not tested the phase computation yet, so be careful using it. I simply left it as is in _v1.

Second, although you may select components from various blocks as Simba suggests, there is no need to split the spectrum into several blocks when making the computation. In fact, you may miss an important component at the edge of a block if you do that. The entire periodicity can be computed in a single pass since the block length is independently computed for each period. But, as Simba says, one picture is worth 1000 words. Here is the spectrum computed in one pass, compared with portions computed in separate passes with limited periodicity.

Regards ...MadCow...

Files:
 

Welcome

MadCow:
Simba..

Thank you for your generosity. I think you have saved me many days of fruitless search. I will use the information as well as I can.

There are a couple of things that I should explain to the forum in case anyone wishes to use _v2 or _v3.

First, the phase computation seems to be in contradiction to the MT4 definition of the MathArctan function. I have not tested the phase computation yet, so be careful using it. I simply left it as is in _v1.

Second, although you may select components from various blocks as Simba suggests, there is no need to split the spectrum into several blocks when making the computation. In fact, you may miss an important component at the edge of a block if you do that. The entire periodicity can be computed in a single pass since the block length is independently computed for each period. But, as Simba says, one picture is worth 1000 words. Here is the spectrum computed in one pass, compared with portions computed in separate passes with limited periodicity.

Regards ...MadCow...

Welcome,

I think that if you don`t split the spectrum into blocks then you are dead..but,ok,np..let`s see in a few months what you think.

I go on holidays for 3 weeks,will try to keep in touch once a week.

Regards

S