# Optimization

## DEFINITION of 'Optimization'

In the context of technical analysis, optimization is the process of adjusting a trading system in an attempt to make it more effective. These adjustments include changing the number of periods used in moving averages, changing the number of indicators used, or simply taking away what doesn't work.

For example, if an investor has a simple trading system that is just composed of a crossover of closing price and a moving average, by changing the periods of the moving average, the trader will get different profits, risk, capital drawdowns, etc. Thus, optimization helps you to choose the optimal parameters to trade.

## BREAKING DOWN 'Optimization'

Once a trading system is developed, the next step before implementation is back-testing and optimization. Finding the best possible combination of settings for the parameters of the trading system is vital to the profit generating success of a trading system. There are many pitfalls and traps that traders sometimes inadvertently overlook. Over-optimization and having too large or to small a sample data period are just a couple of the subtle mistakes that lead to trading systems failing.

## Over-optimization

A trading system is used to define a set of rules that determines the entry and exit of a trade that yields consistent profits. With each rule that is applied within a system, the number of signals is diminished in order to satisfy the collective criteria set forth by the totality of the rules. Applying too many rules to achieve back-test results that show higher profits may result in what is referred to as curve-fitting. This is when the results of a back-test in one time-period shows profitability, but collapses when the same system and settings are applied to a different time-period. For example, imagine a trading system that uses a daily chart over the past year, and selects the month and day on which a major reversal took place, to indicate a signal in the direction of the reversal that yields a profitable trade. The rules of this hypothetical (yet impractical) system would be the list of month-and-day dates (with no year) that would result in the highest net profit for that year. The optimization would tend towards the precise timing of every reversal and result in the perfect (curve) fit. However, when the system is applied to a different year, or the future, it will very likely fail.

## Sample Data Period

The data period duration on which the back-testing is performed to optimize the settings of a trading system varies depending on the system. Some systems generate multiple trade signals per day, and some generate one signal per month or less. In either case, the back-test should, at minimum, include a number of trade signals that will present results that are statistically significant. That being said, care should be taken to ensure that the sample period covers all general market conditions including up trends, downtrends, and range trading. This will help prevent optimization results that work in only one type of market condition.