Building Your Own Trading System – Part 5
Previous articles in this series have discussed why you should build your own trading system, some support tools and algorithms you can use to get an edge. To date we haven’t gone as far as defining our own goals or selecting a platform to make the trading system a reality.
This article will discuss the trading platform selection and the goals of the trading system (which will use MetaTrader, and trade forex).
Firstly, let’s discuss the goals of this particular system. It will be trading the forex market. That is as a result of the global financial crisis, which in my mind has significantly restricted opportunities for stock trading. Since the forex market is highly liquid, not restricted by government regulation (for example, trading halts or bans on short selling) and allows traders to go long and short, it offers a lot of trading opportunities.
It will be a conservative medium to long term system. The holding period will range from a few days out to six weeks. The aim is for a smooth equity curve rather than high profits and high risks.
Since forex is a 24 hour a day, 5 day a week market, I want the system to trade automatically. This means that it should be capable of completely unattended trading without any input from me. My involvement should be to periodically check my account balance.
This trading system will be based around my loess filter algorithm, which is implemented in the Python language. It uses some specialised linear algebra libraries, so I am not keen to rewrite the software. I need a platform that will integrate with my existing software.
MetaTrader is a free platform that allows automated execution of predefined trading strategies. The other contenders are Ninja Trader and Thinking Stuff. All three are excellent automated trading platforms, but MetaTrader seems to have a good blend of power and ease of use.
Whilst MetaTrader doesn’t integrate that well with other programs, it can read and write CSV (comma separated value) files, which is what my Python program uses. However, I’ll have to backtest the strategy outside of MetaTrader, and rely on testing against a demo account in real time before putting my money on the line.
The actual trading algorithm is quite straightforward. As discussed in a previous article, when the indicator shows down, it goes short, when the indicator is up, it goes long. The indicator is based on smoothed data. I’ll need to do some work on trailing stop losses as well. My plan is to based these on market volatility. So when the volatility increases, so does the stop loss, while during flat times, the stop loss tightens up.
In trading, the simpler the algorithm, the more robust the strategy. I am always concerned about strategies that have had a lot of additional rules added, or have been “tweaked” to work with a particular time frame. Invariably, these perform poorly in real life trading.
My first step is to get out my historical data and start testing my algorithm. I have a simple Excel spreadsheet that allows me to tweak everything in real time. My next step is to download MetaTrader (it is free) and start writing some code to integrate my Python program with MetaTrader through CSV file exchange.
Tags: Building Systems

March 16th, 2009 at 9:27 pm
Hi- When one uses a loess filter in trading, and a new data point appears (like today’s close) does the entire time series line that was already on the chart “morph” slightly into a new line, or does the line remain stable and unchanged from the day and week before?
Thanks,
Larry Perlman
larryperlman@optonline.net
April 6th, 2009 at 4:46 am
Hello,
From what I have seen, the line will move around as new data is added. This is because Loess smoothing attempts to fit a high order polynomial to the data. In practice, Loess smoothing seems to work best for trending markets, so it is probably not such a big issue.
July 28th, 2009 at 1:55 pm
Hi,
I’am new in the trading community and I’am very
impressed about your blog. I googled your side
with the ‘python’ and ‘finance’ keywords.
Do you have some examples about your python
filter algorithm? I work with python too and so
I’am interessted about your LOESS python filter
code.
–js