Trading System Anatomy - Part 1 - Building the System

by billb 24. July 2007 11:43

Based on my quest for numbers and information, trading systems entered my life around 2001.  I started writing my own custom built trading systems in C++ around that time.  I soon realized two things, first, I drastically underestimated the infrastructure required from a coding standpoint and second, you have enough rope to shoot yourself in the foot and it hurts in the form of drawdown.  Again, being the slow learner, all I had to do was find the stocks that performed the best over time and just trade those.  Sure enough, the first system that I ever produced took $5,000 and turned it into $9 million in just under 5 years ... in backtesting.  However, those were all the numbers that I needed to be on my way to trade with real money.  Long story short, that $5,000 is no longer $5,000, but I did have enough sense to quit before it was all gone.  Back to the drawing board ...

Back to building the actual trading system.  Fortunately, there are a ton of products out there that fit many needs based on your style.  There is also the option of building your own backtesting software or trading "bot".  The only reason why I wouldn't recommend this is because of the time involved.  You'll spend much more time writing code than developing, testing and finally executing your strategy.  Of course, if the "off the shelf" options do not do exactly what you need (this seems to be less and less the case as these products mature), then you'll have no choice, but I'd consider this a last resort.

The next step is putting your idea into code or into a format that the software understands.  For my quick example, I'm of course, going to use RightEdge.  For simplicity sake, I'm going to create a trading system based on Bollinger Bands.  Bollinger Bands are familiar to nearly all technical analysts, but if you haven't come across them yet ... Bollinger Bands are a technical indicator created by John Bollinger.  The purpose of Bollinger Bands is to provide a relative definition of high and low. By definition prices are high at the upper band and low at the lower band.  Bollinger bands take the specified standard deviation of the closing price (you can use the high, low or open too if you'd like) and plots relative bands around the price action.  The bands are typically shown in pairs.  The lower band represents the center line minus the deviation calculation and the upper band is the center plus the deviation.  Just like fundamental speculation where someone can see the P/E ratio of a company and think it is too high and another can look at the figure and think it is too low, so goes Bollinger Bands.  Some people can read a penetration of the upper band as an overbought condition with a mean reversion forthcoming (and will short), while someone else reads it as a breakout and strong signal to be long.  For our case, we're going to go under the assumption that the band violation is an extreme price situation and a reversal is forthcoming.

To keep it very simple, this system is long only.  For that case, I only plot the lower Bollinger Band and test for a violation.  I've used the drag and drop features in RightEdge to accomplish this.

Quickly, the input BBL is the lower Bollinger band with an input of 20 bars and a deviation parameter of 2.  I've dragged and dropped an "Action" that tells RightEdge to open a long position on the bar following the penetration.  This is a market order.

Now we have our trading system idea in place.  Of course, as time goes on and more testing is performed and knowledge obtained, your trading system ideas will become more complicated, but also more robust.  There is another critical piece of the anatomy and that's money management.  There are a few considerations that are really open to your style and risk management experience.

The trading system properties here make short work of basic money management.  In our case, we're allocating 20% of our portfolio to each position.  With a starting capital amount of $10,000, this would open a position with a maximum of $2,000 per position.  Any subsequent calls to open more positions when less than $2,000 is available will be rejected by the simulator.

The alternate approach is to change the allocation to fixed.  This allocation type will then take what is in the allocation field as a firm dollar amount for each position.  When the amount exceeds the available capital, the open call will be rejected (not enough funds).  The only real disadvantage to this approach is that the value remains static, so as the account value fluctuates (hopefully to the up side), the amount per position does not change.  If you were so fortunate to have your account double or triple over the course of the backtesting run, you may not be getting the full potential out of your hard work with a fixed allocation.

These fields are used for opening new positions, but there is the question of closing existing positions.  Sometimes this is hardest part of a trading plan.  It is very possible to close your trades based on some additional technical criteria or information gathered from other sources, but most software also provides some easy kill switches.  These are in the form of profit targets, stop losses and "time outs".  Profit targets will alert the backtesting software to close positions when a specific price is reached as a percentage of the original buy/short price.  Stop losses in turn, will execute when a particular negative point in the position is reached.  Timeouts are used to close the positions after a certain time has elapsed.  This time is dependent on the frequency of the trading system.  For example, the value of 30 in the timeout field would be 30 minutes in the case of 1 minute bars and 30 trading days in the case of daily bars.

At this point in time, we have a functional trading system complete with money management and haven't had to write a line of code.  In the next article, we'll go through running a backtest or simulation and analyzing the results of that backtest.

Keep in mind, I welcome all questions big or small.  The feedback you provide will drive the direction of future articles.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Trading Systems | General

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen

RecentComments

Comment RSS

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar