How to safely build and test your investment rules

Aim to learn how to create investment strategies that rely on objective testing using mathematical formulas rather than emotional feelings. Rule-based investment systems are the only sure way to build long-term wealth in the markets. However, simply picking two or three moving averages and expecting them to generate profits on your investment account is a sure recipe for a disaster.

Before you put your hard-earned dollars on the line, it is best if you know how to backtest your investment strategies. Backtesting is the heart of quantitative research and is a scientific process of putting your rules into historical data to see if those rules live up to your expectations through past bull, bear and flat markets. Exposing your strategies to past trading data gives you the confidence of how robust they are.

Questionable strategies to the tunes of “buy when the share looks cheap” will completely break an algorithm. Your criteria must be 100% mechanical. What being mechanical means is that you clearly structure your strategy based on these conditions:

  • The entry signal: This is the mathematical fuse or technical setup that trigger a market order. An example of this would be to enter long when price action forms a higher high on the daily or weekly chart depending on your time horizon while the Relative Strength Index (RSI) is rising and crossing up the 30 level.
  • The exit signal: Be clear and definite about your exit to realise your profit even before you enter. An exit signal could be a structural target such as closing the position when the price hits a 3:1 reward-to-risk boundary or when a moving average crosses back under the price line.
  • The risk parameters: This is where you place your stop-loss to protect your investment capital from catastrophic failures. A setup might place the stop-loss exactly one cent below the recent swing low or use a volatility-based metric such as the Average True Range (ATR).

After you clearly defined your conditions, start examining your historical charts. A backtester help a systematic investor process hundreds or even thousands of price bars or candles in seconds.

Let us now have a look at a case study where a failing system on NFLX needs fixing.

Imagine an investor wanted to create a simple mean-reversal strategy to buy NFLX shares when a sharp pull-back happens.

The initial flawed setup looks like this:

  • Asset: Netflix, Inc. (NFLX)
  • Initial entry rule: Buy long if the daily RSI drops below the 30 level while assuming the asset is oversold.
  • Initial exit rule: Sell when the daily RSI crosses back above the 50 level.
  • Initial risk parameter: A fixed 5% stop-loss from the entry price.

When this setup is run against historical data, the strategy delivers a massive trap. During extended stock contractions, NFLX experienced aggressive structural downtrends with its daily or weekly RSI dropping below 30 repeatedly. The system bought the stock as the setup instructed, but a fixed 5% stop-loss proved to be too tight for a high-volatility stocks like NFLX. The results you received were that your strategy was repeatedly shaken out at the bottom of the daily candles right before the stock stabilised. The backtest report revealed a net loss, a dismal 28% win rate and a severely degraded profit factor.

Consequently, you decided to adjust your investment strategy:

  • The adjusted entry rule: Buy long only if the daily RSI crosses up through 30 AND the price closes above its 50-day simple moving average which suggests that the broader trend has turned bullish.
  • The adjusted risk management rule: Changed the rigid 5% stop-loss for a wider, more fluid volatility-adjusted stop-loss set at 3 time the 14-day ATR.

By widening the risk cushion and adding a trend filter, the adjusted backtest now eliminated the false entries during major market downturns. The strategy now successfully held through minor pullbacks, allowing the winning trades to keep running and hit their profit targets.

When you backtest investment strategies, you are on a mission to find out if your strategies have a genuine edge over random events before risking your investment capital. Backtesting provides you with an objective opinion on performance metrics such as your maximum drawdown, profit factor and return volatility. You adjust your investment strategy if backtesting proves that your strategy loses you money under regular market conditions. If this is the case, adjusting your investment strategy is a prudent step before putting your strategy in live trading environments.

Avoid assuming that a good concept on paper will handle live execution seamlessly. Read the investment charts with analytical eyes and check the sample size of your trade history. A strategy supported by 150 historical trades over a period of ten years of history is a robust framework. One backed by ten trades is just a temporary lucky streak.

Leave a Reply