Optimizing and Monitoring a Trading System

After finding rules that work, many traders are tempted to optimize the parameters. This is easy to do, and is the beginning of the end of many solid trading plans.

If trading a simple MACD system, traders usually buy when the MACD difference crosses above zero and sell when it turns negative. With standard software, we can instead test to find the optimal parameter, and perhaps discover that instead of 0.00, the best crossovers take place at 0.31. Our optimized trading plan calls for buying when MACD goes above 0.31 and selling when it falls under that value.

The problem with this optimization is that what we’ve really done is to find out what worked best in the past and this will very likely lead to problems in the future. The optimized value for MACD most likely indicates that the test period included a strongly trending market and we fine tuned the indicator to take advantage of that trend. The same results would not be likely under other market conditions. A nontrending market would obviously be different, but no two trends are ever alike and the optimized value will always change depending on the test period.

Since the 1970s, traders have often believed that markets trend about a third of the time and spend the majority of the time within relatively narrow ranges. Welles Wilder wrote about this idea in his 1978 book, New Concepts in Technical Trading Systems, and his idea has since been confirmed by many other analysts. This insight led Wilder to develop indicators like the Average Directional Index which is available as ADX in most software packages.

By now, many traders will be thinking they can add an ADX filter to the MACD signal and that will yield even better results. With only a few more clicks, they can see which value of ADX works best with MACD. Invariably the test results show even greater profits, a higher winning percentage, and smaller drawdowns. But, traders need to remember that every mutual fund carries that warning stating “performance data represents past performance, which is no guarantee of future results.”

The more variables traders add to the trading equation, the greater the degree of uncertainty and the more likely future results will differ from past performance. Many traders like to point to famous quotes about how history repeats itself, and this is why systems or chart patterns are expected to work in the future. To me, the most apt quote may be from Mark Twain who pointed out that history doesn’t always repeat itself as much as it rhymes. A quick web search reveals there are several versions of the quote, and that emphasizes the point that a general understanding of an idea can be more important than getting everything exactly right. Knowing the essence of what Twain said is “good enough” for all but historians and literary experts.

Traders can benefit from adopting the “good enough” approach to optimization. Some traders use the 200-day moving average to define the trend, assuming that if prices close above the average the trend is bullish and a close below that level is bearish. As a trading system, there is some merit to this approach and a long-only strategy usually delivers market beating results.

At this point, the unavoidable tendency to improve things kicks in and new traders begin optimizing the length of the moving average. Or they will use a more complex calculation to find the best type of moving average, testing an exponential moving average, a variety of weighted averages, or even triangular moving averages. After some testing, they may find that a 163-day front-weighted moving average triples the profits of the simple moving average.

Looking closer at the test results, they can see that the 162-day and 164-day parameters lose money, but they focus solely on the profits. Using the “good enough” approach, they would want to see steady profits when the value used in the moving average formula changes by a small amount. In this example, they’d be looking for all parameters from about 140-days to 180 days to be profitable. This captures all values within 10% of the optimal parameter.

If a small change in a single parameter leads to a big change in profits, it’s a sign that the results are due to random changes in the market action. Small changes in a parameter should lead to small changes in profits. More important than the actual level is the trend of profits. An optimization test should show the profits linearly decline or rise from one test level to the next. That means we should see something like the 150-day moving average show a little less profit than the 160-day and the 140-day even less, while the 170-day moving average delivers even higher profits than the 160-day. While there are many statistical tests for parameter robustness, this visual test is a “good enough” approach and is all traders need to rely on to prevent overoptimization.

In summary, optimization is bad if taken too far because it simply identifies the random variable that caught the greatest degree of the randomness of past price action. Optimization testing is a good way to test the robustness of your trading idea, and the best value to use is the one that shows relatively stable profits as it changes a little bit.

Optimization is often thought of as the last step in the system design process, and it is true that you can start trading after this step is completed. However, the work of system design should never be thought of as fully completed. It is very important to monitor the system you’re trading to make sure that it still works. In reality, no system will always be in synch with the markets. Trend following systems will only work well while the markets are trending, which we’ve known since the 1970s will be about one-third of the time. Most of the time, these systems will lead to many small losses while prices consolidate within trading ranges. These losses are then followed by the occasional big winner that the system is designed to profit from.

Backtest results offer one way to monitor system performance. These reports usually include important information like the maximum number of consecutive losing trades the system has experienced in the past, and the worst drawdown. In-sample performance (results seen during live trading) can be compared to these benchmarks. The future will not be exactly like the past, and experienced traders expect that the worst drawdown will always be in the future. Buy-and-hold stock market investors learned this lesson in 2009. The bear market that followed the internet bubble wiped out about half their account value in many cases. The financial crisis that shook financial markets starting in the summer of 2008 forced them to live through a drawdown that was even more severe.

Rather than relying on the past to see what’s working in the present, we can use the actual performance of the system itself to monitor how it’s doing. This involves just a little more than looking at the percentage of winning trades or other common metrics.

Trading results in wins and losses, and the cumulative effect of individual trades is measured by the account balance. We are back to the idea that all that matters to traders are dollars. Account equity is a data series, just like price data and we can even chart account equity, just like we can chart prices. We can also place a moving average on the account equity.

This idea is not new. Trading legend Larry Williams has described the technique since at least the 1980s, but it is not widely known. No trading system will always be in synch with the market and this is a tool that recognizes that reality. The rules for this idea are simple: when the equity curve falls below the moving average, stop taking the trade signals and resume trading the strategy when the equity curve rises back above the moving average. A 30-week moving average works well on weekly systems, a 10-week moving average is useful for daily systems. Day traders can watch a 10 or 30 period moving average of whatever timeframe they trade.

Trading the equity curve by using a moving average of the system results is a powerful idea that will help traders avoid catastrophic losses. Trading multiple systems can help maximize gains in your account since at least one of the systems should be in the market at any given time.

The next article will address using multiple, uncorrelated systems as part of a complete trading strategy.

By Michael J. Carr, CMT

Trading involves substantial risk of loss and is not suitable for all individuals. Past Performance is not indicative of future results.

Join our newsletter and get a free copy of our trading strategies ebook!