How to Create, Backtest, and Optimize a Trading Strategy

How to Create, Backtest, and Optimize a Trading Strategy

A trading strategy is the process used to enter and exit positions in a market based on quantified signals on when to buy and sell. A trading strategy will have trading plan to express a methodology that defines a trader’s return goals, risk tolerance, and time frame. A successful strategy should have an edge expressed in how trades are entered and managed to maximize gains and minimize losses. 

Creating a trading strategy from beginning to end requires several steps to complete the process.

A trader has to first pick what type of method they want to use to make money. 

  • Scalper
  • Day trader
  • Swing trader
  • Trend trader
  • Position trader
  • Trend follower

What markets will the strategy be trading? There are many to choose from stocks, ETFs, options, forex, futures,  and crypto.

Will a trader be a discretionary trader of mechanical trader and if both what mixture of each. All strategies have some level of discretion built in from building, picking a watchlist, and choosing risk parameters. 

A trading strategy has three primary processes, they are entries, exits, and position sizing. 

An entry signal should get a trader into a trade when the odds of it being a winner are greatest. Whether a momentum signal is entered because the odds are a breakout will continue to go in the path of least resistance or a dip is bought because the odds are that at an extreme oversold level that price will bounce, both setups should have a higher probability of being a winner. 

An exit has two primary purposes, one can be to keep a loss small and the other is to lock in profits while they are still there. A stop loss keeps losses small when the odds are that the trade is not going to work out and a trailing stop signals it is time to lock in a winner when a trend starts to bend. 

Position size is set based on the maximum capital a trader wants to lose if their stop loss is triggered. A position should also not be so big that a trader has issues following their trading strategy because emotions or ego interfere due to the stress of trade size. 

Studying historical charts can allow you to see the nature of trends, price ranges, and volatility on charts over time. Quantifying repeating patterns of price action can help you see how to use reactive technical analysis to structure entries and exits for big wins, small wins, or small losses to create profitability over the long term in your trading time frame. 

Backtesting software is a shortcut to seeing how trading signals would have worked out over time. You can set entry and exit parameters into software to instantly see how a trading strategy would have worked out historically. You can rule out strategies that did not work in the past very quickly and look for signals with an edge. 

In backtesting you can optimize signals that work by slight adjustments to best navigate volatility on a chart. You want to find both maximum drawdowns and returns that are worth the risk and time of trading a strategy. 

A basic backtest will include:

  • Chart selected for the backtest.
  • Entry signal. 
  • Exit signal. 
  • Win rate
  • Average win and average loss size. 
  • Maximum drawdown on capital. 
  • Returns. 

It is important to understand where the edge comes from in a strategy, it is either through a high win rate and keeping losses small or through a smaller amount of big wins while the many losses were kept small. 

There are important considerations to consider when attempting to optimize a trading strategy.

  • All the adjustments to optimize a trading strategy must be quantified with new parameters and backtested. 
  • The new optimized adjustments for signals or position sizing must be backtested on adequate historical data through multiple market environments. 
  • A second backtest on new optimized parameters needs a big enough sample size of data to create statistically meaningful results, not be tested on select market environments to improve past performance. 
  • Keep adjustments simple, changing less strategy parameters and variables helps to avoid overfitting.
  • Keeping two sets of data to use on backtesting helps from being fooled by randomness. Testing in sample data, optimizing and then testing new out of sample data helps show what really works to improve results. 

The live trading of a backtested system will help a trader more fully understand the effort, discipline, frustration, stress, and screen time needed to execute it in real time with capital at risk. An ideal trading strategy will allow a trader to feel comfortable in its execution whether losing or winning in understanding the expected win/loss ratio and drawdowns. The trader needs confidence in a trading strategy and faith in their self to execute it consistently over time. 

Many times a trader will adjust position sizing and risk exposure of a trading strategy in real time as they understand how it can perform under different market environments. 

Successful trading is the long term evolution of the trader and the strategy to optimize what best works for them. The best trading strategy is the one that you can follow consistently with minimum stress and maximum gains. Your trading should make you feel like you are running a business not going to a casino for high stake gambling. 

  • How to Create, Backtest, and Optimize a Trading Strategy