From the December 01, 2006 issue of Futures Magazine • Subscribe!

A structured approach to trading systems

A modern mechanical trading system requires two major components: good tools and good structure.

The first requirement refers to the trading platform used to evaluate your rules, produce reports, charts, etc. Although there are many options out there, you want a platform that can test how you’ll trade. That means a platform with a fully integrated portfolio, money management routines, flexible charting tools that work in live trading and a broad system development environment that doesn’t restrict you to just a few ideas — or even a few hundred ideas.

Even more important than the platform is the structure of the trading system, though that is intimately related to the platform you use. In today’s fast moving and fast changing markets you need a structure that can adapt and a platform that will allow you to adapt it quickly. There are a few different basic structures of mechanical trading systems.


The simplest type of a mechanical system is the stop-and-reverse system. These systems have one buy rule and one sell rule and are always in the market. Although not used often for the final complete approach, this type of simple system provides an idea of how predictive a strategy is on bullish and bearish moves during the testing process.

A classic example of this type of system would be the simple unconditional channel breakout. Another example of a stop-and-reverse system would be the triple moving average crossover. The code for both of these systems is shown in “Stop and reverse” (below).

Another category of mechanical trading system uses separate entry and exit rules, which can even be based on different analysis logic. A good case can be made for this approach. With entry rules, a trader wants a strong statistical edge that the market will move in the direction that is expected. The goal of a good exit rule is to get out of a trade where the expected future return is not worth the anticipated risk, or to protect against a loss that will hurt the ability to stay in the game. The code for an example system is shown in “Different strokes” (above).

Most systems offer multiple entry opportunities. There are also multiple ways to exit a trade. For example, there could be a reversal stop, a normal exit and a protective stop. We can even assign an exit to a given entry. “Multiple rules, same direction,” page 48, demonstrates ways this can be done.

When developing a system, you generally want to have multiple ways to enter and exit a trade. The component system approach brings to light a common problem that a system developer needs to balance. The problem is that flexible entry and exit rules, sometimes called filtering, is a good way to make signals more reliable, but care needs to be taken to make sure the filters do not cause the system to miss a move or enter on the wrong side of the market.


In a system, there are buy entries, sell entries, exit longs and exit shorts. A position can be entered or exited on a stop, at the next day’s open or on a limit. Modern trading systems have a standard procedure for applying code to market data. They process each bar of data individually and test the rules in the code on that bar only. If the rules say to act, trade orders are placed for the next bar. If the rules return a false value, the program moves to the next bar.

This is true whether systems are considered indicator-based (a moving average system), pattern-based (an Elliott Wave system) or fundamentally based.

However, all trading rules are composed of two parts: a condition and an order. Here is an example of an entry order:

If Close < Open and Close > Close[39] then

Buy(“Entry1”,1,High + .3*Range,stop,day)

End if

This is a compound condition that enters a position at today’s high plus 0.3 times today’s range during tomorrow’s trading day. Notice the first argument, “Entry1” which is the name of the entry signal. Naming the individual entry orders is an important practice to follow when exits are developed.

Here is a simple unconditional order using channel breakout:


Any condition can be used for an entry order, but there are only three entry methods. These are stop orders, limit orders or market orders. It is critical to select the best entry method for your system. Stop and limit orders place conditions on the market; “market” and “enter on close” orders do not. You must test with the order types you will trade with.


The purpose of protective stops is to prevent against a large loss from a given position. Many traders use a hard dollar stop that exits a position if the loss reaches a given value. An example would be a $3,000 stop loss. This type of stop leads to an artificial loss level, which has nothing to do with the analysis of the market being traded. A smarter version of the stop loss is to let the market action tell you when to exit. Examples include formulas to set exit prices such as these:

For stops on short trades use:

Entryprice - 6*Average(TrueRange,40,0)

For stops on long trades use

Entryprice + 6*Average(TrueRange,40,0)

Trailing stops are another tool for protecting profits and preventing winning trades from becoming losing ones. In a trailing stop, there is a profit level where the stop order entry is triggered. It could be a dollar level or when the profit for the trade has reached 10 times the average true range. Next, the stop is set. The simplest version to use is some percentage of the gains attained to reach the trigger level. A more technical stop could be developed such as using the last swing low for a long trade or swing high for a short trade. In any case, the idea is to set the stop and have it follow the progress of the trade so that it locks in profits while letting the profits continue to run.

Ultimately, though, the trade must be liquidated and that’s where profit goals come into play. Target profit goals are designed to capture windfall profits that occur because of major events in a market. A simple target profit goal would be to exit a trade if it has made 20 times the three-day average true range or prices are at a level that is four standard deviations from the average. Target profit goals can be used to exit a single contract or to exit one contract of a multiple contract position (see “When to liquidate,” below).

When tested in the natural gas market, the use of the target profit exit increased profits and reduced drawdown versus the standard stop and reverse version of the system. This system entered two contracts in the natural gas market at the 20-day high. One contract was exited at the target profit and the second contract was exited at the standard exit.

A 20-bar breakout system produced $352,620 with a $49,000 drawdown on just a little more than 49% winning trades from Jan. 3, 1991 to Sept. 15, 2006. Using the target profit goal increased profits to $422,650 while the drawdown dropped to $46,830 and the percentage of profitable trades moved to more than 59%. It is worth noting that 10% of the trades that hit target profits eventually became losing trades in the future.


The method you use should depend on the markets you are interested in trading and the time frame you want to trade. What works for one person with a particular set of goals, account size, market access, trading platform, etc., will not necessarily work for another person. Some viable methods are based on price action. These can be applied to a variety of markets and are good choices for larger portfolios. Two of the more common methods that fall into this category would be trend-following methods and opening-range breakouts.

However, some markets are poor performers. Stock index markets do not perform well with trend-following methods because the markets tend to be quite choppy. Another example would be that opening-range breakout methods do not work well on markets with low volatility because the breakouts do not hold, and a good system might only capture 20% of the average daily range. If a market has low volatility, this number may not be large enough to make a system tradable.

There are also price-action methods that relate to a given market or group of markets. Examples of this type of method are the buy-the-dips type of systems that were used in the stock index markets during the 1990s until the tech bubble burst in 2000. Obviously these systems assume a bull market scenario.

This buy-the-dips system was first published in the 1990s:

Sub BuyDips(LookBack)

If Highest(Close - Close[1], Lookback, 0) < 0 Then

Buy(“”, 1, NextOpen(0) +0.4*Average(Range, 3, 0), Stop, Day)

End If

If Highest(Close - Close[1], Lookback, 0) > 0 Then

exitlong(“”,””, 1, NextOpen(0) - 0.6*Average(range, 3, 0), Stop, Day)

End If

End Sub

Testing this system on stock index data, from April 22, 1982, until Sept. 15, 2006, with no deduction for slippage and commissions, provides these results (the Dow and Russell futures were tested only on the years those contracts were available):

Market and net profit

Russell 2000 futures: $258,350

Dow 30 futures: $20,530

S&P 500 futures: $301,400

This type of system improves risk-adjusted returns and is not in the market for long periods. It was developed for the S&P 500 but the same rules worked well in the Russell 2000 in recent tests, but not in the Dow Jones index.

Price pattern recognition is another often-used methodology in trading systems. This is actually thousands of different methods grouped into one category. Some patterns work well across many markets, such as gap patterns. Other patterns will only work in a single market because the pattern data mined a particular data set.

The key to pattern-based trading is to make sure the patterns have enough supporting cases and actually make sense. If a pattern does not make sense, it is possible to fool yourself because when “A” happens and B occurs does not mean that “B” is caused by “A”; correlation does not equal causation.

A classic example of spurious correlation is the theory that the Super Bowl winner can predict stock market trends. According to the theory, when an old American Football League team wins, it foreshadows a down market. However, a winner from the old National Football League means the bulls are going to run.

The Super Bowl indicator has been on the money 30 out of 37 times, which represents a success rate of more than 80%. In 2005, the New England Patriots’ defeat of the Philadelphia Eagles in Super Bowl XXXIX correctly predicted a down market, as the Dow Jones Industrial Average finished the year slightly below its 2004 closing (-0.8%).

Of course, this relationship is nonsense, but it illustrates the need to be careful in developing patterns and evaluating whether the rules make sense. Not all spurious correlations are nonsense on the surface. It is important to take a little time to develop a hypothesis as to why they work.

As they are some of the flexible pattern-based methods, gaps are important. Gaps are traded in two ways: there are patterns to profit from closing gaps and patterns to profit from the market continuing in a given direction. The first are called reversal gaps and the second are called continuation gaps. Code for a simple gap system is shown in “Gaps R Us” (below).

This code is for the Oops pattern popularized by Larry Williams about 20 years ago, which still works today. Tested on the full-size S&P 500, Nasdaq and the Russell 2000 going back to 1982, this system made $939.36 per trade with profits divided evenly between the long and short side ($1,064.45 compared to $824.79). This pattern works because people who bought on the up-gap or sold on the down-gap panic when the gap is closed and prices move back into yesterday’s range. This creates the short-term moves that the Oops system exploits.

Other types of systems rely on internal market information. The stock market indexes have rich collections of information that are not available in other markets. Included are the advancing issues, volume in component stocks, declining issues and volume in other stock indexes. This information is available for the New York Stock Exchange Index, Nasdaq and the American Stock Exchange index. This market internal information is very powerful and is often used in creating intermediate and long-term market timing models.

Another valuable approach is intermarket analysis. This can be thought of as a type of instantaneous fundamental analysis (see “The truth about intermarket analysis,” December 2005).

The logic behind intermarket systems is that there are markets which are predictive of other markets. One example is S&P 500 and the 30-year Treasury bond. T-bonds are considered predictive of the S&P 500. If the S&P 500 is in a downtrend and T-bonds are in an uptrend we go long stocks. If T-bonds are in a downtrend trend and the S&P 500 is in an uptrend we go short stocks. Another example is the relationship between the T-bonds and silver. These markets are negatively correlated. When silver is in an uptrend and T-bonds are in an uptrend, you sell T-bonds. When silver is in a downtrend and T-bonds are in a downtrend, you buy T-bonds.

The goal of this series is not to provide ready-to-trade mechanical systems, but to provide solid examples of trading systems that are effective in today’s markets. That said, these are just the core concepts that can be better adapted. In our next installment, we will design two original trading systems and show how trading them together can increase returns and reduce risk.

Note: Boxed formulas are available online at in downloads area.

Murray A. Ruggiero Jr. is a consultant in East Haven, Conn. His firm, Ruggiero Associates develops market-timing systems. He is editor-in-chief of Inside Advantage Gold Club and is the author of Cybernetic Trading Strategies (John Wiley & Sons). E-mail:

About the Author
Murray A. Ruggiero Jr.

Murray A. Ruggiero Jr. is the author of "Cybernetic Trading Strategies" (Wiley). E-mail him at

comments powered by Disqus
Check out Futures Magazine - Polls on LockerDome on LockerDome