Building Your Own Trading System – Part 2

In the last article on “Building Your Own Trading System”, I wrote about identifying your trading goals.  There is no point in building a system if you don’t know what you want to achieve out of it.

This article is about trading system algorithms.  It aims to give you an understanding on how to interpret price data to identify buy and sell points, and some hints on how to do this mathematically.  As far as I am aware, this information is not available elsewhere.

Firstly, this is a huge area, so I’ll focus on only a small part in this article – finding changes in trends.  Secondly, to do this well takes some advanced maths – don’t give up because you only need to understand the principles, not the maths.

What is the problem with price data?  It is noisy.  Is an uptick the start of a trend change, or is it random noise?  If price data was smooth, it would be fairly easy to trade – whenever the trend changed, you’d buy or sell.  So the solution is to smooth the data out.  Every major trading technique attempts to do this – to separate the true “signal” from the random noise.

Also, sometimes the market trends, and other times it is range bound.  Volatility varies from day to day.  This is a big challenge for smoothing data.  Most approaches don’t cut it.

Most traders are using moving averages.  A moving average is simply the average of (say) 10 previous periods.  You can change the smoothness by increasing the number of periods.  This means that random price movements tend to be smoothed out in the same way as an average of monthly sales smooths out the ups and downs.  Moving averages are simple to calculate.

By definition, moving averages lag the market (by about 1/2 the number of periods in the moving average).  In my view, this makes them useless for trading, except as an example of what smoothed data looks like.  By the time a moving average turns up or down, the market has already passed its turning point.  Irrespective of what you do with moving average crossovers, triple moving averages and medians, the problem is the same – lags make moving averages unprofitable.

If you think of market prices as a signal with an underlying direction obscured by noise, an analogy is a noisy telephone line or radio signal.  There are well developed techniques for removing noise from such signals.  One approach is Fourier analysis.  This is useful for finding cyclical patterns.  Since price data doesn’t neatly fit into this, we won’t consider it further.  You can use Kalman filters, or local regression approaches.

The technique that I have found to be the best is Loess smoothing.  This attempts to fit curves to the data.  There is one smoothing parameter, alpha.  The higher the alpha value, the smoother the curve.  This technique has minimal lag, but needs a fair bit of computer power (which has only become available in the last few years).  Loess smoothing is covered in this Wikipedia article.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • YahooMyWeb
  • StumbleUpon
  • Google Bookmarks
  • Mixx

Pages: 1 2

Tags: , , , , ,

2 Responses to “Building Your Own Trading System – Part 2”

  1. Hi- I ran across your post while searching for information on whether the loess filter can be applied to stock prices. Do you use publicly available software such as Caterpillar SSA? I would be interested to find out how I could use that data filter in the markets.
    Thanks,
    Larry Perlman
    Parsippany NJ USA
    larryperlman@optonline.net

  2. Hello,

    The software is custom written in Python. However, Loess smoothing is a relatively common addition to packages such as Matlab.