Trading Strategy Optimizing: Example and Definition with Backtesting

Is strategy optimization good in trading? Are optimizers error maximizes? Do small input errors result in large output errors?

Strategy optimization in trading is good if done correctly and below you can read how to optimize a trading strategy. Optimization has negative associations for many traders, just like curve fitting, but optimization done correctly can give you valuable inputs and a better understanding of your strategy. If you know what you are doing, you should run an optimization test of all your backtests. We give you two simple (and naive) examples of how to optimize.

When you start live trading with a backtested strategy, you frequently get disappointed: the results are far away from the indicated results in the backtest. How could this happen after spending days backtesting your strategy? For new traders, this might come as a surprise, but for seasoned traders, this hardly comes as a surprise. The reason might be the optimization and curve fitting of your backtest.

(Before we go on we’d like to mention that we have a backtesting course that covers all aspects of how to backtest.)

What is strategy optimization in trading?

First, let’s define what optimization strategy in trading really is:

Merriam-Webster defines optimization like this:

….as an act, process, or methodology of making something (such as a design, system, or decision) as fully perfect, functional, or effective as possible specifically : the mathematical procedures (such as finding the maximum of a function) involved in this.

Optimization is no different when it comes to trading. You look for the best variables or parameters and then search and optimize for the best settings for those variables. With today’s computing power, a software program can easily be programmed to find the best optimization for a certain strategy. It’s literally done in seconds and the software needed is cheap and good. In this article, we use Amibroker to optimize:

Is strategy optimization good in trading?

Yes, trading optimization is good when it’s done correctly and you know what you are doing. It’s good because you get a better understanding of what is making the trading strategy perform well, and you get to understand how the variables of the strategy influence the end result.

Trading optimization lets you easily understand if your backtest is based on luck or randomness. For example, if you have a trading strategy that goes long when the price breaks above the 25-day moving average, you can optimize it by changing the number of days in the moving average. If you find out that the results are much worse close to 25 days, you get a pretty strong indication that the original strategy most likely is down to chance and randomness. Hence it’s unlikely to be very successful in the future.

Instead of being ignorant to optimization, you should optimize every backtest you do. An optimization is, in reality, a test of how robust your strategy is. When you examine the variables, you get a much better understanding of your strategy: is it due to chance/luck or might it be something worth trading or testing out of sample?

An example of strategy