08:13 AM, 02 Mar 2024 (AUS EST)   The market is currently closed       

Creating a Trading System

Whether you are trading stocks, options, CFDs, commodities or FOREX, finding a profitable trading system is no easy task. Master traders will guard their systems like a pirate does gold. Many systems will work well for a set period of time, and then cease generating profits as conditions change. Or one system may work for one individual but not another because of a specific personality and risk profile. How do you find a system that works for you? One solution is to create your very own trading system.

How do you go about creating a system? What are some statistical checks and balances that you can employ to raise the odds of it being a winning system?

Problems Creating a Trading System

Backtesting is the process of taking a trading theory and testing it out on historical data. Backtesting is one way to prove that your system has worked in the past and that it may work in the future. If you have used backtesting software before, you may be aware of the danger in using it to build a trading strategy. What is the caveat? In one word: data-mining.

Data-mining is where you dig into the data first and build a system around it. You may screen for stocks using filters and rules without rationale to isolate stocks that have historically went up. Data-mining is where you already know the answer (or which stocks rose best) and you attempt to build a question (or set of filters) that will match it.

For instance, over the past 10 years small gold stocks rose dramatically. Your data-mined system might be built around trading small gold stocks. But will small gold stocks continue to go up in the future? As well, banking stocks fell over the past few years. Will they continue to fall? Because the system was built from data-mining, your entire system is faulty.

Making a Thesis

To create a trading system you first need to have a premise or a thesis to start from. You should begin with a point of view before digging into the data. Your viewpoint may be shaped by hunches or instinct, but more often it comes about by reading, courses, and experience.

For instance, I may notice that most stock portals advertise 52 week lows and highs. My thesis may be that the wide coverage these stocks lead to increased trading – with a profitable boost. I may also believe that individual traders are more influenced by 52 week highs and lows than are institutional traders. If I want to target these stocks that are mostly traded by individuals, I might gravitate toward lower priced shares with less liquidity.

Having a belief or a reason for your trading system is important. If you base your future trades by what has worked in the past, you are lacking a reason for the system to work going forward.

Creating Rules

Next you will need to come up with a clearly defined set of rules. When to buy and when to sell are your two most important rules.

  • Your entry rules may be a set of parameters that must all be met, or it may be a set of rules that ranks criteria and gives it a score out of 100. There are many variations on creating rules.
  • Your selling rules may be based on holding for a certain amount of time, selling if a certain profit or loss threshold is reached, or when certain fundamental or technical criteria are no longer met.

To create your trading rules you will need a firm grasp on macro- and micro-elements that affect the trading system. For instance, the strategy may require a bull market but also high trading volume in the individual stock. It may require low interest rates, but also a pharmaceutical company.

Testing On a Data Set

Next, you will want to test your theory. To do so you will need fundamental or technical backtesting software. Fundamental backtesting involves using balance sheets and income statements in addition to profit or valuation ratios such as price-to-earnings. Technical backtesting software will use share price and volume in addition to programmable indicators. A service that provides a mix of the two is best.

To begin you will need a certain set of data to test your theory on. Perhaps you can pick a few years of trading information from local markets to test your rules on. For example, I might test the theory on all stocks in the ASX between the years 2001 and 2004. Does the theory broadly hold up?

You can also optimize your rules to a certain degree. For instance, your 52 week low rule might work if you hold no longer than one week, but it may fail if you hold for one month. Tweaking at this level is okay.

Checking for Robustness

Now you should have a system that works well over a certain window of time. You will need to test your strategy out with different entry and exits to check for robustness. As an example, your strategy might be to buy a certain stock and to hold for 4 weeks. Your scan is run across three years of data and the theory holds up. Next, start your entry on week 2 and try it over the three years again. Then start on week 3 and finally on week 4. This will ensure that you didn’t accidentally pick the best starting week. You may not think this will matter much, but it can have huge differences if you stumble across favorable entry points that have nothing to do with your strategy. Maybe you accidentally picked the one week of the month where stocks performed best.

Your backtesting software should allow for this type of robustness checking.

Other Sample Periods and Countries

After rigorously testing your strategy out in the sample period, you will want to test it out in a new sample. Randomly pick another multi-year period and check for robustness. You may even choose to test your strategy in other countries. Keep in mind that certain strategies will work better in certain markets. For some reason, momentum trading does not work in Japanese markets – but it does so in every other country.

Walk Forward

If you tested your trading system out during 2005 – 2008, you may be curious to see whether it continued to work until today. This is called walking forward as you test your strategy out from 2009 until now.

If you use the most current data in step one to make your strategy, it will make it very difficult to perform a ‘walk forward’ test. You will need to wait months or years as you test your strategy out in the real world. If you use an older data set as your starting point, you can walk forward without having to wait a long period of time. As you walk forward you should use the robustness check as you use a range of entry points.

Running Statistics

Last, you might be wondering whether this strategy is worth the risk. There is no perfect method to determine risk, but one way is to compare volatility to reward. If the system historically earns you 4% per period but whips up and down 10% during the same time frame – it may not be worthwhile. This is the concept of the Sharpe ratio that compares gain to standard deviation. In general, you would hope to find a Sharpe ratio of 1 or more – which means your average gain is higher than the average volatility. Another test is the Sortino ratio which only compares the gain to the downward volatility.

An Example of Creating Your Own Trading Strategy

Here is an example of a real trading strategy and how it can be tested.

Thesis. It is my belief that upgraded stocks should make good short-term buys. New market conditions or stock specific information is picked up by analysts and the stock future earnings are forecast upwards. Investors may be slow in coming across this information as it is disseminated over a few weeks. After many weeks when the information or upgrade is old, the boost in price may subside. Stocks with previous big earnings surprises may be the ones watched most closely by traders.

Creating Rules. My rule set will be to include stocks with the recent quarterly earnings surprise being at least 50% above expectations. The next year’s earnings forecast must be revised up by at least 5% over the past 4 weeks. The stock should have enough daily volume to lower risk of slippage. As well, the stock needs to have performed at least as well as the broad market over the past 52 weeks to root out falling stocks that I feel are higher risk. I plan to scan the market once a month and hold the stocks for 4 weeks before selling.

Testing on a Data Set. My initial data set will be 2004 – 2007. I will rebalance my portfolio every 4 weeks to hold the stocks meeting my criteria. My initial results show that I earn an average of 2.84% per month with this strategy, or 198% total over the three years.

Checking for Robustness. Next I test this strategy out, still between 2004 and 2007, but I also include weeks 2, 3, and 4 as an entry point with one month holdings before selling. Thus, my strategy will be carried out roughly 160 different times in the sample period. My average monthly gain holds up at 2.65%.

Other Sample Periods and Countries. I will next use the time period of 2002 – 2005 to test my strategy. With my robustness check the average monthly gain stays at 2.72%. To test this out on other countries I include a rule that will only test stocks which do not have headquarters in the USA – or foreign stocks traded in US markets. Checking for robustness between the years 2002 – 2005, I find a 3.4% monthly gain.

Walk forward. I will next test my strategy from 2007 until today. I am fully aware that it will take me through the major market crash – but my strategy did not include market timing rules so I must trade through it. The system, when checking for robustness, returned 0.75% monthly.

What this tells me is that I need to go back to the drawing board and consider how to factor in the macro-economic cycle that includes bull and bear sentiments. Or it may need slight optimizations only such as shortening up the holding period to factor in today’s volatile market. Then again, I may need to use more stringent rules to re-focus on smaller stocks traded by individual traders.

The strategy appears to be overall sound but it needs more refinement before trading.

Ready to Begin?

Creating a strategy is no easy task. Remember that the most important piece of the puzzle is the why. Why do you think this is a sound strategy? If you have a reason why this technique will work, there is a stronger reason to believe that it will work in the future.

Next you need to run your idea through a battery of tests that will use a variety of time frames, entries, exits, and even sample universes. In general, the simpler your system is the more likely it will work in the future. If you have dozens of complex signals that isolate only a couple of rocketing stocks, your likelihood of finding another couple of stocks with abnormally high gains diminishes and the probability that you data-mined an unrepeatable result occur goes way up.

Last, test your strategy out in the real world with real money to discover parameters you may have overlooked such as liquidity. Guard your secret well (or sell it if that is your objective) and be on the lookout for when a strategy begins to fail. A failing strategy is not a useless one. This may offer you the opportunity to add in factors, such as market timing, or the techniques may need a complete overhaul. Designing and creating a trading strategy can be fun and rewarding, but much care needs to be taken to ensure it is statistically sound.