Trading Strategies Based On Digital Filters - page 55

 
dvarrin:
So the indicators you have implemented are based on MESA and DFG is based on MESA too?

Yes. But I don't know what kind of preprocessing DFG performs on timeseries.

And the number of bars we can choose in DFG is the same like the number of bars you're using in your indicator to perform the spectrum analysis?

Yep.

About the number of bars to use. Why do you want to take the most recent price history? It looks really noisy with no well defined cycle in it. What I'm doing is to take more and more bars, increasing by 1000 or 2000 bars, until the spectrum analysis lokks almost the same. This would mean that the peaks in that spectrum where significant for a long time and then should not be so bad?

You are at the heart of the problem! And that's the main reason why I have shared my indicators.

MESA is nearly perfect for extracting stationary cycles from an arbitrary long, gaussian-noisy, timeseries (while one of the constraints of FFT is 2^n length. You can always zero-pad your timeseries, but it's a workaround).

When it comes to real market timeseries, as you know, you neither have gaussian noise nor stationary cycles.

You have "something" that you can call a signal + noise. The signal have some cyclic behaviour. The thesis of who sustains that you can trade cycles, is that you can separate signal from noise and that you can recognize cycles inside signal and take advantage of the cyclic behaviour by means of some sort of prediction. That's the approach of NOXA cycles, for example, and of part of original Ehlers trading solutions and indicators (MESA8).

The approach of ATCF and others (i.e. Codebreaker) is that you can do trend following in a better way if you know how to filter the signal from noise. That's the reason why is necessary to know the spectrum of the timeseries and that's what I have worked on.

That said, you have to find out if it is better for your trading strategy to have an averaged, more stable set of digital filters based on the hypothesis that some cycles are recurent on a long timeseries.

When you observe a long timeseries (2000 bars) with MESA, then you are averaging all the cycles inside that timeseries and extract the bands in which most of the spectral power is condensed. If there are recurrent well known cycles then you have clean peaks. More often, as you examine longer timeseries, peakes tend to widen and lower (thus the are converging, as you say). That means that you can only have an idea of the bands in which you have spectral power, but not clean cycles.

If you prefer a more reactive adaptation to changing markets, or if you want to catch a temporary well defined cycle, you have to shorten the window of observation (which is my peculiar field of study, and for which I needed an inline analyzer instead of an off line like DFG)?

The problem that arise in this last approach is : How spectrum changes bar by bar and how does MESA behave in the short term analysis?

Despite the fact that I am convinced that denoising and detrending is very not useful with MESA (at least in a long window of observations and with gaussian noise), I am doing some trials in this short term approach on real timeseries. It seems that detrending can help to better catch medium length cycles (the ones in between 60 and 150 bars), which could lead to a better SATL curve.

Anyway you can choose any time span as long as you have bars in the history for your inline analisys with my indicators.

If we look at the adaptive indicator showing the values for P1 and D1, we can see that the curve is quite smooth, exept at some places where the values are making a big jump to another value, before returning to the normal one. Don't you think that the best is to ignore those jumps?

Sliding the window of observation (i.e. as time passes) peaks move inside the spectrum. Not only they change their center, but they get higher or lower. When it happens that an old predominant cycle is surpassed in sharpness by a new one, you have a jump.

I have developed an algorithm to get the most significant peak (the one with the highest heigth/width ratio) and that's the way I choose the predominant cycle.

As I am taking into consideration only the most representative peak, jumps happen when a new one becomes predominant.

When you have jumps it means that the old peak is decreasing and a new peak is rising. You could stick with the old one, but what for?

 

again

richcap:
Krzysztof,

maybe it would be better to have a slower signal for a meaningful simulation.

As you can see, MESA can extract perfectly the signal peaks, even without denoising or detrending, but it happens that they are too quick for a trading strategy based on cycles.

If you have an 8 bar period (0.125 frequency) or even a 13.3 bars period ( 0.075 frequency), it means that you have 4 (6.5) bars for fast uptrend and 4 (6.5) for fast downtrend. Even a spectacular digital filter introduces some lag, say at least 2 bars .So you have only 2 (4.5) bars to trade a fast trend. Sum it with a noise of amplitude bigger than the signal (4 towards 3) and you have a completely non-cycle-tradable signal.

I like the idea of testing a signal with 2 or 3 sinusoids + DC component+linear trend+noise of different types. I would suggest something like 20bars (0.05 freq), 50 bars (0.02 freq), 100 bars (0.01 freq).

Here it is

t = (0:5000)';

f0 = 0.05;

ph0 = pi/6;

f1 = 0.02;

ph1 = -pi/6;

f2 = 0.01;

x = 10+0.1*t+2.5 * cos(2*pi*f0*t + ph0) + 3 * cos(2*pi*f1*t + ph1) + cos(2*pi*f2*t) + 4 * randn(size(t));

Look at the spectrum from MATLAB. Goertzel and FFT are dead without detrending.

Krzysztof

Files:
1_1.jpg  50 kb
2.jpg  49 kb
3.jpg  45 kb
4.jpg  51 kb
usdsek5.rar  60 kb
 
richcap:
Yes. But I don't know what kind of preprocessing DFG performs on timeseries.

Yep.

You are at the heart of the problem! And that's the main reason why I have shared my indicators.

MESA is nearly perfect for extracting stationary cycles from an arbitrary long, gaussian-noisy, timeseries (while one of the constraints of FFT is 2^n length. You can always zero-pad your timeseries, but it's a workaround).

When it comes to real market timeseries, as you know, you neither have gaussian noise nor stationary cycles.

You have "something" that you can call a signal + noise. The signal have some cyclic behaviour. The thesis of who sustains that you can trade cycles, is that you can separate signal from noise and that you can recognize cycles inside signal and take advantage of the cyclic behaviour by means of some sort of prediction. That's the approach of NOXA cycles, for example, and of part of original Ehlers trading solutions and indicators (MESA8).

The approach of ATCF and others (i.e. Codebreaker) is that you can do trend following in a better way if you know how to filter the signal from noise. That's the reason why is necessary to know the spectrum of the timeseries and that's what I have worked on.

That said, you have to find out if it is better for your trading strategy to have an averaged, more stable set of digital filters based on the hypothesis that some cycles are recurent on a long timeseries.

When you observe a long timeseries (2000 bars) with MESA, then you are averaging all the cycles inside that timeseries and extract the bands in which most of the spectral power is condensed. If there are recurrent well known cycles then you have clean peaks. More often, as you examine longer timeseries, peakes tend to widen and lower (thus the are converging, as you say). That means that you can only have an idea of the bands in which you have spectral power, but not clean cycles.

If you prefer a more reactive adaptation to changing markets, or if you want to catch a temporary well defined cycle, you have to shorten the window of observation (which is my peculiar field of study, and for which I needed an inline analyzer instead of an off line like DFG)?

The problem that arise in this last approach is : How spectrum changes bar by bar and how does MESA behave in the short term analysis?

Despite the fact that I am convinced that denoising and detrending is very not useful with MESA (at least in a long window of observations and with gaussian noise), I am doing some trials in this short term approach on real timeseries. It seems that detrending can help to better catch medium length cycles (the ones in between 60 and 150 bars), which could lead to a better SATL curve.

Anyway you can choose any time span as long as you have bars in the history for your inline analisys with my indicators.

Sliding the window of observation (i.e. as time passes) peaks move inside the spectrum. Not only they change their center, but they get higher or lower. When it happens that an old predominant cycle is surpassed in sharpness by a new one, you have a jump.

I have developed an algorithm to get the most significant peak (the one with the highest heigth/width ratio) and that's the way I choose the predominant cycle.

As I am taking into consideration only the most representative peak, jumps happen when a new one becomes predominant.

When you have jumps it means that the old peak is decreasing and a new peak is rising. You could stick with the old one, but what for?

How do you trade using the ACTF signals? Do we have an opened position for more than two bars? I would like to see a chart with the entries and which indicator is telling us to enter. SATL for example could have a big delay and price can move already very far before SATL flattens. And if we follow FATL, then we can be wrong. It would be really nice to see a chart with those ACTF entries.

 

non stationary CHIRP ??

richcap:

MESA is nearly perfect for extracting stationary cycles from an arbitrary long, gaussian-noisy, timeseries (while one of the constraints of FFT is 2^n length. You can always zero-pad your timeseries, but it's a workaround).

I love this stationary/non stationary business. CHIRP is stationary or not stationary ?? It changes frequency and amplitude so as a process is non stationary but MESA worked anyway...Maybe when you make DF test than it will show that it is stationary.

Krzysztof

 
fajst_k:
I love this stationary/non stationary business. CHIRP is stationary or not stationary ?? It changes frequency and amplitude so as a process is non stationary but MESA worked anyway...Maybe when you make DF test than it will show that it is stationary. Krzysztof

Hi Krzysztof,

You have no idea how much I'm enjoyng our brainstorming (or perhaps you share my fun ;-) )

Yes, your chirp signal is definitely non stationary but...

...as it is changing slowly, I can define it quasi-stationary in a window of observation and MESA can do it's job, as you have seen.

If I have a window of 400 bars in which the chirp signal frequency (or it's reverse: period) changes from 260 to 220 bars, MESA will have no problem in giving back a quite clean peak at something between 220 and 260 (see post #496).

If you take a bigger window, you will have a less definite peak, giving account to the fact that frequencies are spread through a wider band (see post #495).

That's about the tradeoff between sharpness and stability of spectrum that dvarrin was talking about.

The shorter the window, the more quasi-stationarity of the signal.

 
fajst_k:
Here it is

t = (0:5000)';

f0 = 0.05;

ph0 = pi/6;

f1 = 0.02;

ph1 = -pi/6;

f2 = 0.01;

x = 10+0.1*t+2.5 * cos(2*pi*f0*t + ph0) + 3 * cos(2*pi*f1*t + ph1) + cos(2*pi*f2*t) + 4 * randn(size(t));

Look at the spectrum from MATLAB. Goertzel and FFT are dead without detrending.

Krzysztof

I have applied the same simple strategy used before. You have two main frequencies to trade (20 and 50 bars period while the one with 100 bars of period has a very small amplitude respect to noise and is hardly tradable).

In the first picture you see strategy applied to slow trendline (50 bars) and in the second you see strategy applied to fast trendline.

They are both profitable. I must say that this noise is helping because after a cross between trendlline and it's reference there is a high probability of getting a noisy and profitable price arrival on the other side to ride the trend.

As always when you have a primary trend (up in this case), it would be more profitable to trade only upwards

Files:
 
dvarrin:
How do you trade using the ACTF signals? Do we have an opened position for more than two bars? I would like to see a chart with the entries and which indicator is telling us to enter. SATL for example could have a big delay and price can move already very far before SATL flattens. And if we follow FATL, then we can be wrong. It would be really nice to see a chart with those ACTF entries.

Let me quote the answer to a similar question that was asked to me by email:

Hi G.,

i only said I'm interested in mid-short windows (200) because I want my filters to change as soon as market changes. But you can use the indicators for longer windows. I'm happy that you are experimenting. The only limit is the horse power of your PC (even if there is a maximum of 500 for degree, but you can change the constant that defines it in the library, if you want) and the fact that the degree must be less than length, otherwise MESA fails in finding poles.

You can play with the parameters and understand what they mean:

Max (80) and satlmin (15) mean that you are not interested in peaks with period bigger than 80 and smaller than 15 for your satl.

Min (10) mean that you are not interested in peaks with period smaller than 10 for your fatl.

I guess that you gave not enough space between satl min and fatl min, but maybe you are right.I seldom change the degree parameter, but of course you can try. It is in this trial and error process that I see a win/win situation in sharing the code (if you share yor results, of course)

Note that if algorithm fails in finding important peaks with the constraints that you put, default settings are used to calculate fatl and satl. Always take a look at the output in the experts tab of terminal window.

Riccardo

G. wrote:

> Hello again, i have been trying many configurations for your adaptative indicators for works in H1 i got that i want more or less, but i read in your last post on TSD that is better use a little lenght parameter, why? also i would like to know how what does the degree parameter.

> I have been modifing the initial time parameter and i haven't seen any change in the lines.

>

> What I can do for get a FATL and RSTL like the original?

>

> The best set that i have found is for h1 is in order:

> degree 100

> lenght 1000

> max 80

> min 10

> saltmin 15

>

> Regards
 

methodology

In the first picture you see strategy applied to slow trendline (50 bars) and in the second you see strategy applied to fast trendline.

They are both profitable. I must say that this noise is helping because after a cross between trendlline and it's reference there is a high probability of getting a noisy and profitable price arrival on the other side to ride the trend.

Hi,

First I hope methodology is OK. Just reexamine once more way of settings of parameters to be sure that the knowledge what we are looking for does not affect your settings. Otherwise we will have future leaks or curve fittings.

As always when you have a primary trend (up in this case), it would be more profitable to trade only upwards

Thats the problem. 'Cycle mode' and 'Trend mode' using Ehlers terminology.

We can try to get rid of this but maybe later.

Maybe you will detrend this by log difference and we will see if performance improved.

Than I will make the test for CSSA on the same data let's see.

I hope Goertzel team which read every mail from this forum will post their EAs

results as well on this data.

Krzysztof

 

So the idea is:

The degree is like a multiplier of the length value.

The lenght value is how much bars the indicator uses for smooth the data, more bars, more smooth, and the indicator becomes less adaptative.

Is correct this?

 
richcap:
I have applied the same simple strategy used before. You have two main frequencies to trade (20 and 50 bars period while the one with 100 bars of period has a very small amplitude respect to noise and is hardly tradable).

In the first picture you see strategy applied to slow trendline (50 bars) and in the second you see strategy applied to fast trendline.

They are both profitable. I must say that this noise is helping because after a cross between trendlline and it's reference there is a high probability of getting a noisy and profitable price arrival on the other side to ride the trend.

As always when you have a primary trend (up in this case), it would be more profitable to trade only upwards

Richcap,

If I'm not mistaken, I believe you are basically trading the FTLM and STLM slope changes in their devolved, but optimized, state, which can very well in fact be profitable (It is the way I trade ATCF). Wonder what would happen if you trade them in conjuction w/ each other.

I still haven't had a chance to really get into those indies you posted (J.O.B.), but better believe I haven't forgotten them either. You guys are on a role. I will do my best to post more (though I don't have much I can think of that I can contribute). Thanks again, everybody, for keeping this thread alive.

Reason: