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.

Loess smoothing calculates a number of regressions.  It isn’t a mathematical technique you can just do in Excel out of the box, but if you have a tool like Octave, R or Matlab, Loess smoothing is an available function.

At present, I have a custom written Loess smoothing algorithm that was developed to my requirements by a PhD, for some custom written stock selection software that runs under Unix.  It can smooth data essentially immediately on my dual core MacBook Pro.  Although it is low on my priority list, I would like to see this as an Excel add-in.

If you are interested in reading further about this exciting approach, check out this link (Black Art of Smoothing).

In conclusion, this article is about identifying the problem that most traders never define - the need to smooth data in their trading model, and presents a solution that is now feasible for use.

I’ll continue with building your own trading system in future articles.  As always, I appreciate your comments and feedback.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • YahooMyWeb
  • StumbleUpon
  • Google
  • Mixx
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Tags: , , , , ,

Leave a Reply