Trading System Design: Test Your Edge

Finding a logical reason that your trades should work is the first step in coming up with a market beating strategy. After that, testing is required to be certain your idea actually works in the market because, in the end, markets are driven by emotions and logic will sometimes fail in the face of that.

You can test any idea with a software package, and many easy to use tools are commercially available. Most will require an investment in both time and money. Required programming skills will vary with the product selected. Some require a great deal of those skills while others rely on plain English to create strategies. With little effort, you can find the product that’s right for you.

Cost is often a hurdle for new traders. Software packages make it easier to test ideas and spot potential trading opportunities. However, it is possible, with a dedicated effort, to test your idea without specialized software. Free price data is available from a number of sources and could be loaded into a spreadsheet. Spreadsheet functions can be used to define almost any technical indicator in the spreadsheet, and if/then features could be used to obtain test results. Spreadsheet traders should plan on spending many hours to complete a project like this.

For those wanting to trade with chart patterns, programming these ideas in any software is difficult. Back testing in this case is usually limited to a review of past price action, noting the buy and sell signals on the chart and adding up the potential profits. Hindsight bias is almost unavoidable given that you’ll know the general market trends. Past results from these tests are very likely to be optimistic, but chart patterns have provided profits to disciplined traders. For those who believe their edge lies in their ability to spot patterns, paper trading is a good idea before committing real money to their dreams.

Paper trading involves noting buy and sell signals in real time and writing down what you’d do with real money on the line. Before opening a trading account, every new trader should do at least a month of paper trading. This involves analyzing the market and identifying the actual entry and exit points, in advance. Paper trades need to be identified ahead of the market action which makes it different from historic back testing. Both play an important role in system development and neither step should be skipped. Paper trading helps you to be certain you actually understand the steps involved in trading, in addition to demonstrating the viability of your edge.

Back testing is intended to quantify your edge, and good software will provide you with several numbers that help. To illustrate the ideas, an example will be helpful. For testing, we’ll use the SPDR S&P 500 (SPY), an exchange traded fund that tracks the popular stock index. Each buy will be for 100 shares, which means traders could use this strategy with an account of $15,000 or less. Testing will be on a long-only system, since short stock sales are really beyond the risk tolerance of new traders, and novices should gain experience with margin accounts before using this type of order. We’ll use weekly data, based on Friday’s closing price since we want a system that anyone, even the time-challenged trader, can follow.

Beginning with the system logic, we want to enter the market by looking for an oversold condition as a buy point and we’ll exit when price becomes overbought. There are many technical indicators that help identify market extremes, They usually require some degree of subjectivity, such as how low the indicator should be before it is oversold, and when to time the buy after that. MACD, the Moving Average Convergence/Divergence indicator, provides a simple level of objectivity to the analysis and offers clear rules. Many web sites explain how to calculate and apply MACD, and it could be done in a spreadsheet. As a quick summary, MACD takes the difference between two moving averages of the price. The distance between the averages rises and falls as prices move higher and lower, and the indicator itself gets larger and smaller. Looking at a chart, we can see that it generally crosses zero around the time price trends change. MACD reaches a large negative value when prices become oversold, and it will generally move towards zero as the price decline ends. Our logic is that upward momentum is required for prices to move higher, and we’ll use reversals from negative to positive momentum as a buy signal, closing the positions when momentum turns negative.

We will tell our software to buy when MACD crosses above zero, and close the long position when it falls below zero. Any trading software package will deliver the results in a few seconds. If we began trading this idea at the end of 1999, we’d see that we had 7 trades, 5 of them were winners, and we’d have made a profit of $3,278 in our account. It’s important to consider bull and bear markets in the test period, and starting at the beginning of 2000 ensures that we include two very challenging bear markets.

Designing a system means figuring out if these numbers are good or bad. The percentage of wins in this case (71.4%) is extraordinarily high. By itself, this number tells us nothing, and while many traders will look at the percentage of wins as an important number, they should focus on other data points in deciding whether or not to trade the system.

Total profits are important, but need to be placed in context. Profits need to be compared to an alternative strategy. In this case, we will look at a buy-and-hold strategy as the alternative. Buying an S&P 500 index fund at the end of 1999, an investor would have shown a small profit on their $15,000 investment and would have $16,459 in their account at the end of May 2011, assuming all dividends were deposited the account and held as cash. Without dividends, the account shows a small loss. An investor following the simple MACD strategy would have an account balance $18,278. This is meaningful, the rewards, measured by total dollars and including the impact of dividends on a buy-and-hold strategy, are greater for the system. If buy-and-hold beat the strategy, we would stop the analysis and move on to the next system to evaluate.

Profit factor is often used to look at how well the system performs. This number is the ratio of the total winnings to the amount of dollars lost in losing trades. It’s a nice idea, but doesn’t reflect the real world. There are a number of variations on this idea. Payout ratios, Sharpe ratios, Sortino ratios and many other calculations are used to quantify the risk relative to potential rewards. They overlook the fact that we are traders and nothing except dollars in the account really matter at the end of the day.

We captured the rewards with a simple idea. If gains in the strategy beat the alternative, the system passes the first test. Some will annualize the number, but that’s really an unnecessary step. The percent gained per year isn’t important because we pay our bills with dollars, and that’s where the focus in testing needs to be.

Risk should also be measured in dollars. Drawdowns represent the only risk that matters. That shows the decline our account would suffer in the worst losing streak. If those losses are too high to bear, then we can’t trade the system, no matter how profitable it appears to be. That actually makes system evaluation fairly easy. The risk is defined as the worst drawdown.

Buy-and-hold turns out be very risky by that measure. Our baseline risk would measure the amount lost by investing $15,000 in an S&P 500 index fund at the end of 1999. The worst drawdown in that account occurred in March 2009, and was $6,256. This can be thought of as a 42% drawdown, and is less than the price decline of the S&P 500 because dividends helped offset losses. Using the MACD system, the largest drawdown was only $1,655. Risk, measured in dollars was reduced by 75% with a simple strategy.

Based on these results, the weekly MACD system is worth considering as a cornerstone of a trading strategy. It’s invested about 26% of the time, and avoids the worst of the market declines. For those who are curious, short trades were also profitable over this timeframe and the drawdown is slightly larger, but still significantly lower than buy-and-hold.

Many beginning traders are intimidated by trading system math, but it doesn’t need to be confusing. Think of the rewards in dollar terms, compared to a buy-and-hold strategy or another trading system if you’re deciding which of the two to trade. Risks are equivalent to drawdown. Nobel prizes have been awarded for defining more complex measures of risk, but those are most useful for academics that pay their mortgage with their teaching salaries. Traders think in dollars and drawdown is really the only risk number that matters.

By Michael J. Carr, CMT