# Digital Signal Processing in Trading

There is a concept of trading or observing the market with signal processing originally created by John Ehler. He wrote three books about it.
Cybernetic Analysis for Stocks and Futures

There are number of indicators and mathematical models that are widely accepted and used by some trading software (even MetaStock), like MAMA, Hilbert Transform, Fisher Transform (as substitutes of FFT), Homodyne Discriminator, Hilbert Sine Wave, Instant Trendline etc. invented by John Ehler.

But that is it. I have never heard of anybody other than John Ehler studying in this area. Do you think that it is worth learning digital signal processing? After all, each transaction is a signal and bar charts are somewhat filtered form of these signals. Does it make sense?

-
Im not sure that just because Ehler's indicators are included in trading software means widely accepted. I dont think there is an objective way to answer this, especially the part about getting a masters degree. – stephenw Feb 15 '11 at 22:03
@stephenw: I have removed that part but have you googled "hilbert sine wave" and seen the results? – ali_bahoo Feb 15 '11 at 23:05
Marcos Lopez de Prado and Riccardo Rebonato worked on something similar recently called Kinetic Component Analysis. I tried to make an algo out of it on Quantopian to backtest because in the paper they offer python code. I could not get anything sensible out of it but that may have been my execution. – user25064 Nov 17 '14 at 14:20

Wavelets are just one form of "basis decomposition". Wavelets in particular decompose in both frequency and time and thus are more useful than fourier or other purely-frequency based decompositions. There are other time-freq decompositions (for instance the HHT) which should be explored as well.

Decomposition of a price series is useful in understanding the primary movement within a series. In general with a decomposition, the original signal is the sum its basis components (potentially with some scaling multiplier). The components range from the lowest frequency (a straight-line through the sample) to the highest frequency, a curve that oscillates with a frequency maximum approaching N / 2.

How this is useful

• denoising a series
• determining the principal component of movement in the series
• determining pivots

Denoising is accomplished by recomposing the series by summing up the components from the decomposition, less the last few highest frequency components. This denoised (or filtered) series, if chosen well, often gives a view on the core price process. Assuming continuation in the same direction, can be used to extropolate for a short period forward.

As the timeseries ticks in real-time, one can look at how the denoised (or filtering) price process changes to determine whether a price movement in a different direction is significant or just noise.

One of the keys, though, is determining how many levels of the decomposition to recompose in any given situation. Too few levels (low freq) will mean that the recomposed price series responds very slowly to events. Too many levels (high freq) will mean for fast response but , perhaps too much noise in some price regimes.

Given that the market shifts between sideways movements and momentum movements, a filtering process needs to adjust to regime, becoming more or less sensitive to movements in projecting a curve. There are many ways to evaluate this, such looking at the power of the filtered series versus the power of the raw price series, targeting a certain % depending on regime.

Assuming one has successfully employed wavelet or other decompositions to yield a smooth, appropriately reactive signal, can take the derivative and use to detect minima and maxima as the price series progresses.

Problems

• One needs a basis that has "good behavior" at the endpoint so that the slope of the curve at the endpoint projects in an appropriate direction.
• The basis needs to provide consistent results at the endpoint as the timeseries ticks and not be positionally biased

Unfortunately, I am not aware of any wavelet basis that avoids the above problems. There are some other bases that can be chosen that do better.

Conclusion
If you want to pursue Wavelets and build trading rules around them, expect to do a lot of research. You may also find that though the concept is good, you will need to explore other decomposition bases to get the desired behavior.

I don't use decompositions for trade decisions, but I have found them useful in determining market regime and other backward looking measures.

-
Could u elaborate a bit more, or provide references, on the above problems with wavelets? And if i am not too intrusive, what tools do u use for trade decisions? – user670 Mar 29 '11 at 14:38

You need to investigate how to differentiate interpolation methods versus extrapolation methods. It's easy to build a model that repeats the past (just about any interpolation scheme will do the trick). The problem is, that model is typically worthless when it comes to extrapolating into the future.

When you hear/see the word "cycles", a red flag should be going up. Dig into the application of "Fourier Integral", "Fourier Series", "Fourier Transform", etc, and you'll find that with enough frequencies you can represent any time series well enough that most retail traders can be convinced that "it works". The problem is, it has no predictive power whatsoever.

The reason Fourier methods are useful in engineering/DSP is because that "signal" (voltage, current, temperature, whatever) typically repeats itself in the circuit/machine where it was generated. As a result, interpolating then becomes related to extrapolating.

In case youre using R, here's some hacky code to try:

 library(gam)

#Generate and plot a 1000 data point time series
x <- 1:1000
y <- cumsum(rnorm(1000))
plot(x, y, type="l")

#Fit the first 500 points using a Generalized Additive Model (it'll fit anything)
#The red line is an example of interpolating
gam.object <- gam(y[1:500] ~ s(x[1:500]))
lines(1:500, predict(gam.object, data.frame(x=1:500)), lwd=2, col="red")

#Now, predict the future points
#The blue line is an example of extrapolating (from an interpolation model)
lines(501:1000, predict(gam.object, data.frame(x=501:1000)), lwd=2, col="blue")

#Now, notice the difference in the "fit" of the blue line versus the red line.


-
Hi Jonathan, when you say: "There are some other bases that can be chosen that do better" which bases do you mean? I'm studying the subject now and haven't found anything useful in the usual suspects (Daub, Symm, ..). – MisterH Mar 28 '11 at 11:25

Ehler's website has a technical papers section where there are papers available for free download, with code, so you can try things out for yourself. I personally have taken some of his ideas and combined them with other reading, forums etc. on the net and think that applying DSP to trading shows great promise and is definitely worthy investigation. If you are interested, I am blogging about my progress in applying these principles here.

-

Cycle analysis and signal processing might be useful for seasonal patterns but without knowing more about the performance of such an approach to trading I would not consider a degree in signal processing for just trading. Would you be happy applying what you learn on standard engineering type problem because that may be what you'll be stuck doing if it doesn't work well enough with trading.

-

The DSP techniques you're referring to are great for repeating signals, but not suitable for random signals (like price movements). While there are some techniques suitable for picking weak signals out of large noise environments (GPS is one that comes to mind), those techniques depend on knowing what the signal looks like, and if you knew what the signal looked like, you'd own the market.

-

DSP and Time Series analysis are the same thing. DSP uses enginering "lingo" and time series analysis uses mathematical "lingo" but the models are quite simular. Ehler's cyber cycle indicator is an ARMA(3,2). Ehlers has some unique ideas: What is the meaning of the phase of a random variable?

-

Forget all these so called "Technical indicators". They are crap, especially if you don;t know how to use them. My advice: buy a good wavelet book, and create your own strategy.

-
Hi fRed, which wavelet book did you use? Can you recommend a title? – MisterH Mar 28 '11 at 11:26
An Introduction to Wavelets and Other Filtering Methods in Finance and Economics by Ramazan Gencay, Faruk Selcuk Brandon Whitcher – RockScience Mar 29 '11 at 2:15

I've found John Ehler's Fisher Transform quite useful as an indicator in trading futures particularly on Heikin-Ashi tick charts.

I rely on it for my strategy but I don't think it is reliable enough to base an entire automated system on its own because it has not proven reliable during choppy days but it can be quite useful on trend days like today. (I'd be happy to post a chart to illustrate but I don't have the reputation needed)

-