Trading Strategies Based On Digital Filters - page 72

 

It is great help

Thanks for your kind help by posting. It is a great help to me.

Best wishes to all you guys

 

Great

Boyens:
I download the #MFT_STLM2_v2 indicator posted by the great Simba, but didn't work for me on my plataform.

This version expired or something?

I'm looking for a STLM MTF to define the trend.

Thanks in advance friends.

Kindly.

Boyens,

Find them here,you need both compiled in your indicator folder for the MTF to work,then,you can attach just the MTF and play with it,I suggest that you use h4 and/or d1 for trend definition on lower tf charts.

Regards

S

Files:
stlm2.mq4  11 kb
 

Alternatives for calculating FATL SATL, etc.

Somehow I have my doubts about this multiple cyclic model of the FX market. I don't mean to challenge the utility of indicators based on the model, but I wonder what can the sources of such resonant structures be? Typically resonance requires a delayed reaction to a stimulus. The resonant structure resonates at a period equal to the delay. What can be delayed for 200 hours in this information age? (Perhaps the resonance might be more easily explained if it occured at smaller periods in the M1 TF). What can the stimulus be? News?, Fear and Greed of traders acting as a group? An interesting sociological question, but not useful here.

A second objection is the fact, pointed out by Simba, that the periods of resonance do not match up when measured at different TF's. If there is truly a resonant structure at say 48 1H periods, then it should show as a resonance at 12 4H periods, or 192 15M periods. This does not seem to happen. Why? Doesn't it make you nervous using the cyclic assumption to trade?

Whatever the answers, if the indicators are useful, then there are alternative ways to compute them. We do not need to rely on continuous spectral analysis and adaptive digital filters once we are convinced that there are 2 or 3 cycles that dominate, and that they change frequency (period) and amplitude slowly, etc. We can use FFT's, MESA, Goertzel or whatever to convince ourselves of this... I am not convinced yet, although the 3d pictures are pretty convincing. Then we can use tried and true methods to extract the cyclic signals from each other and from noise.

This signal extraction problem is pretty common in designing communication systems. Just think how your radio receiver (or cell phone if you must) pulls it's signal from the background noise and other signals in the neighborhood. These signals are not stationary, nor is the noise, though it is usually modeled that way. They are pretty complex with varying phase, frequency, and amplitude. Yet they can be reliably extracted in low signal-to-noise environments, provided that they do not interfere with each other.

How about using three fixed bandpass filters with bandpass narrow enough to separate the 3 signals, but wide enough to pass the expected frequency variation. Each filter is followed by a phase-locked loop to extract the changing frequency, and a coherent demodulator to extract the amplitude. No spectral analysis required. (Except to select the three bands.) No relative importance required, and no on-the-fly design and modification of filters required. (The extracted signal will be phase-continuous).

All of these elements are either filters, multipliers, or an oscillator with digitally controlled frequency (VCO). The only filter that has an important frequency response is the loop filter, and there are many designs for these. I have many references if anyone is interested. If I can just get my memory to cooperate so that I don't forget what I am trying to program, and if I can resurrect some semblance of coding in C, I may try it myself.

MadCow

 

Data preprocessing

Richcap, thank you for sharing your code.

Do you know this other version of MESA, writen for Amibroker ?

AmiBroker - AFL Library

It implements various preprocessing (filtering, detrending) that are not included in your code, and that you could benefit of as it should allow for better results on real data.

Hope it will help you.

 

Resonant

MadCow:
Somehow I have my doubts about this multiple cyclic model of the FX market. I don't mean to challenge the utility of indicators based on the model, but I wonder what can the sources of such resonant structures be? Typically resonance requires a delayed reaction to a stimulus. The resonant structure resonates at a period equal to the delay. What can be delayed for 200 hours in this information age? (Perhaps the resonance might be more easily explained if it occured at smaller periods in the M1 TF). What can the stimulus be? News?, Fear and Greed of traders acting as a group? An interesting sociological question, but not useful here.

A second objection is the fact, pointed out by Simba, that the periods of resonance do not match up when measured at different TF's. If there is truly a resonant structure at say 48 1H periods, then it should show as a resonance at 12 4H periods, or 192 15M periods. This does not seem to happen. Why? Doesn't it make you nervous using the cyclic assumption to trade?

Whatever the answers, if the indicators are useful, then there are alternative ways to compute them. We do not need to rely on continuous spectral analysis and adaptive digital filters once we are convinced that there are 2 or 3 cycles that dominate, and that they change frequency (period) and amplitude slowly, etc. We can use FFT's, MESA, Goertzel or whatever to convince ourselves of this... I am not convinced yet, although the 3d pictures are pretty convincing. Then we can use tried and true methods to extract the cyclic signals from each other and from noise.

This signal extraction problem is pretty common in designing communication systems. Just think how your radio receiver (or cell phone if you must) pulls it's signal from the background noise and other signals in the neighborhood. These signals are not stationary, nor is the noise, though it is usually modeled that way. They are pretty complex with varying phase, frequency, and amplitude. Yet they can be reliably extracted in low signal-to-noise environments, provided that they do not interfere with each other.

How about using three fixed bandpass filters with bandpass narrow enough to separate the 3 signals, but wide enough to pass the expected frequency variation. Each filter is followed by a phase-locked loop to extract the changing frequency, and a coherent demodulator to extract the amplitude. No spectral analysis required. (Except to select the three bands.) No relative importance required, and no on-the-fly design and modification of filters required. (The extracted signal will be phase-continuous).

All of these elements are either filters, multipliers, or an oscillator with digitally controlled frequency (VCO). The only filter that has an important frequency response is the loop filter, and there are many designs for these. I have many references if anyone is interested. If I can just get my memory to cooperate so that I don't forget what I am trying to program, and if I can resurrect some semblance of coding in C, I may try it myself.

MadCow

Hi Madcow,

200 hours delayed reaction in the financial markets will lead to extinction of the players that purported that behaviour and,consequently,the behaviour would dissappear....as you rightly hinted to.

IMHO there may be different causes of cycles,if you read the materials at the Foundation for the Study of Cycles,you may see that among the noted probable causes they cite the stars,the planets,the solar flare activity,geomagnetic storms,etc,etc,so many causes that it is best to just study the possibilities in private, while trading the effects when they are quantifiable on a reward to risk basis.

Basically ,IMO,cycles are like a preset chain of action reaction behaviour that usually takes similar time to be accomplished from week to week,day to day,hour to hour(think about predator&prey models)..how much time does it take to run the sell stops and then fullfill that big customer buy order at a better price?...How much time takes for your competitor to notice and start intruding in your game?how much time does it take for the previous longs to either be stopped out or chickened out of their positions(and there is a component of volatility here) ?..Well,I believe that this process takes ,usually,x time,+- y std...so,as long as the std is workable and the y doesn`t kill you in the waiting,this patterns are tradable.

In conceptual trading terms,if 2 or 3 hours after Frankfurt opening,with the London session going on,I see prices stall at a weekly S1 after a downmove that just went fast and furious 50 pips below previous support(aka running of stops)...and,simultaneously my H4 cycles are signalling a turn,I take the long.

Currency pairs may have a near optimal compression of volatility at H4(all tfs compress volatility from tick data),and the lower timeframes may be too noisy for our filters to detect the cycles....Or maybe,and very probably ,our filters are not good enough for that.

Please feel free to go ahead with your idea,it may offer an alternative view about this fascinating issue...I believe most of the people here will try to help you.

Regards

S

 

Interesting post..

Does anyone know how did Noxa to modify the SSA algorithm in order to make it causal?

I've been working on the subject for the past two moths, but haven't got much time to wrap it up.

I read in some of the posts of this thread that Noxa CSSA uses neural networks??? Can someone corroborate this?

By the way, just a multilayer feed forward NN or maybe a auto-encoder NN?

 

'' Casual'' part comes from echo state network :Echo state network - Scholarpedia

But still SSA algorithm nothing but curve fitting.

 
SIMBA:
Hi Madcow,

...

Please feel free to go ahead with your idea,it may offer an alternative view about this fascinating issue...I believe most of the people here will try to help you.

Regards

S

Thanks Simba for the explanation and encouragement, but before I proceed I want to make sure that the cycles are not a figment of the way the price is processed. I would like to ask whether the cyclic components could possibly be the result of aliasing.

Let me show you what I mean. Here is GBPUSD M1 and two spectral plots from R_MESA. The first plot is the spectrum of GU M1 with no processing. The second is the spectrum of GU M1 after passing it through an anti aliasing filter designed so that the signal can be sampled at 1 hour intervals without violating Nyquists sampling theorum. If the M1 signal is simply sampled at 1 hour intervals, without first low pass filtering (and that's precisely what the H1 close is), the subsampling process will introduce aliased artifacts. Because the M1 close has significant energy below 120 min period, sampling at 60 min will alias a lot of energy into the H1 samples. All the peaks that show left of 120 minutes will appear as peaks in the H1 spectrum. The location of the peaks can be calculated, but the process is a mess, so I have not done it. Also MESA may not pick up all the aliased energy, like an FFT would.

Now lets look at the spectrum of GU H1 with no anti aliasing filter applied.

Where did all those peaks come from? If I was the church lady, I might think it was SATAN... but in fact I think it is aliasing. Perhaps I should subsample the filtered M1 price and look at it's spectrum. But that's for another day.

Incidentally, thanks to RC for the excellent software tools.

Regards... MadCow...

P.S. Think how much more we can alias into the H4 spectrum.

Files:
 

H4,Nonlinearity and Fractal scaling

MadCow:
Thanks Simba for the explanation and encouragement, but before I proceed I want to make sure that the cycles are not a figment of the way the price is processed. I would like to ask whether the cyclic components could possibly be the result of aliasing.

Let me show you what I mean. Here is GBPUSD M1 and two spectral plots from R_MESA. The first plot is the spectrum of GU M1 with no processing. The second is the spectrum of GU M1 after passing it through an anti aliasing filter designed so that the signal can be sampled at 1 hour intervals without violating Nyquists sampling theorum. If the M1 signal is simply sampled at 1 hour intervals, without first low pass filtering (and that's precisely what the H1 close is), the subsampling process will introduce aliased artifacts. Because the M1 close has significant energy below 120 min period, sampling at 60 min will alias a lot of energy into the H1 samples. All the peaks that show left of 120 minutes will appear as peaks in the H1 spectrum. The location of the peaks can be calculated, but the process is a mess, so I have not done it. Also MESA may not pick up all the aliased energy, like an FFT would.

Now lets look at the spectrum of GU H1 with no anti aliasing filter applied.

Where did all those peaks come from? If I was the church lady, I might think it was SATAN... but in fact I think it is aliasing. Perhaps I should subsample the filtered M1 price and look at it's spectrum. But that's for another day.

Incidentally, thanks to RC for the excellent software tools.

Regards... MadCow...

P.S. Think how much more we can alias into the H4 spectrum.

Madcow,

A picture is worth a thousand words...see attached a scan I run to find and draw a composite cycle slope of up to 4 cycles(per timeframe) in different timeframes

H1..Looked for cycles up periodicity between 90 to 180 bars within the last 540 bars

M30,M15,M5...Same equivalent analysis...so basically I am oversampling 1,2,4 and 12 times with exactly the same results.

If you see the pics you will see that the scan found just 2 cycles,not 1 nor 4, exactly the same 2 cycles in the 4 different timeframes,same periodicity 108 and 153 H1 bars equivalent,same amplitude and same phase...This doesn`t happen always,aliasing and ghosts and spectral resonance of harmonic and subharmonics usually appear in the picture fogging the reality,but when you see this perfect match,you know you can trade this cyclic model,at any of the 4 timeframes ...even at h4 if you wished to do so....by using oversampling,you can sample several times per bar(use m15 sampling in h4 for example)...but you really do not need to.

The cycles are exactly the same...what are the possibilities that these are ghosts?...As I told you before it is just a question of having the right tools to measure what is happening...

Richcap may disagree with my view,but,IMO,MESA is not the right tool,Fourier with all its variations,including Goertzel ,is slightly better...but what we really need to think about is the concept of Fractal Cycles,so,we have to enter into the realms of nonlinearity and fractal scaling if we really want to "model" the market.

I won`t try to convince anybody of anything else,I already have all the tools I need in the realm of cycles,so,if you are not convinced by both Richcap and mine findings,then the logical conclusion is to forget about cycles..If you are convinced,or at least convinced enough to try,I will help you as long as your approach is original and useful and,obviously,as long as I don`t have to disclose any propietary work done at our private Group.

Regards

S

Files:
campc19.gif  41 kb
campc20.gif  40 kb
campc21.gif  36 kb
campc22.gif  36 kb
 

Simba,

those are very convincing results. I'm not sure just what I'm looking at, but the curves are very similar for all TF's. It seems that there is not really an aliasing problem, however, I'm lost to understand why not. The H1 series should have significantly more noise, than the M1 series. Apparently there is no sustained high frequency cyclical component in any if the lower TF's, and there is little or no noise. This seems incredible to me, and since I went to some trouble to try to understand the possibility of aliasing before you posted, I would like to post my thoughts.

My concern about aliasing may not be clear, so let me illustrate the effect of aliasing better than I have. For ease in illustration, let's assume that the spectrum of an M1 price series consists of two periodic components embedded in noise. The noise has a triangular spectrum, one of the components is at a low frequency (long period, shown in blue) and the other is at a high frequency (short period, shown in red). Since we are dealing with an M1 price series, the spectrum must end at the sample rate/2 (fs/2) (period = 2 minutes). ( If higher frequency components exist in the transactions, they will be aliased into the spectrum below fs/2). Further, assume that both components have reasonably good signal to noise ratio. This is all shown in the top half of the first figure below. The effect of subsampling this price series at 5 minute intervals (M5) is shown in the bottom half of the figure. This can be graphically computed by noting that the spectrum of a sampled signal can be found by convolving the spectrum of the original signal with a series of impulses at the sampling frequency. ( Since the M5 period is 5 times the M1 period, the sampling frequency is 1/5 the 1 minute sampling frequency as shown. )This involves the simple steps of overlaying the initial spectrum at each impulse. It's pretty clear what a mess this makes of the original spectrum. Notice that the high frequency component is aliased down near the low frequency component, but the low frequency component is not affected.

The effective spectrum of the M5 price series derived by subsampling the M1 series is shown in the figure below. On the left I tried to show how the noise builds up due to aliasing. On the right I show the final spectrum of the M5 signal. The high frequency component has been aliased down near the low frequency component, and the noise has built up so that the signal to noise ratio is now pretty bad.

Now suppose that there were several high frequency cyclical components in the original spectrum, and suppose that we subsample it once every hour, or once every 4 hours. The resulting mess should have cyclical components all over the place, and the signal to noise ratio should be terrible.

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.

It seems that you have already looked at the various TF's and are satisfied that the cyclical components are present at a low enough frequency that they are not affected by subsampling. By using something like the Goertzel algorithm, (or simply a set of narrow band filters, which is equivalent) one can apparently ignore the noise added by aliasing. This is good news. I am convinced that the components are there. Don't know why. So I will proceed to look at a phase locked tracking filter.

I would like to hear more about fractal filtering if you have some sources.

Thanks ...MadCow...

Files:
Reason: