# Momentum Investing Experiment and Question

I was thinking yesterday about what would happen if I followed the following investment strategy:

1. Let A, B, and C be the stock price two months ago, last month, and today, respectively.
2. If A > B < C, purchase as much of the stock as you can, as the price just started rising.
3. If A < B > C, sell all of the stock, as the price just started falling.

Basically, the idea is being a day late on when an Oracle would choose to buy/sell a stock. I downloaded historical data of the S&P 500 since 1871 and wrote a Python script to test out my idea. The data only has a resolution of a month, so I ended up breaking it down into 10-year intervals, to see whether the strategy above would be better or worse than just buying and holding for the entire period.

The result was that, over a total of 1647 10-year periods, the strategy above won 1172 times, and lost the other 475 times, meaning it was a better choice slightly more than 70% of the time for any given 10-year stretch.

I am fairly sure my code is accurate, but if my conclusion seems wildly off, let me know. My main question though is as follows: Did I (re-)discover a strategy that is risky but, on average, better than passively investing, at least with regards to historical S&P 500 data? There are two large periods of losing when starting between 1942 and 1960 and when starting between 1970 and 1992, which drives the success rate to about even when looking at the last 100 years. Is there some assumption I am making that explains why this strategy would not work as well as it seems to? I highly doubt I came up with a brilliant market-shattering investment strategy.

• Are you factoring in the cost of executing trades? Are you assuming you can always sell for the price at point of initial decline? Jul 20 '18 at 16:53
• @HartCO "Are you assuming you can always sell for the price at point of initial decline?" This will be a big potential flaw. As wella s the fact that you seem to indicate 'better' or 'worse', but not quantifying. The 475 times it failed, did it fail more than it gains on average? Jul 20 '18 at 16:54
• Moreover without getting into specifics of this plan, note that you are attempting to create a mathematical model based on past events, to forecast future ones. The market of 1871 is unrelated to the market today, so I would ignore the first many decades. Even the market of 2000, or 2007 is quite different from the market today. It is easy to fool yourself into thinking you have found the 'solution' to the market. Harder to actually do it (I would say, impossible). Jul 20 '18 at 16:56
• Finally, I will point out that the mere fact you believe you have found something that works ~2/3 of the time, indicates that you are likely erring verrrrrry significantly in one of your assumptions. Someone with a system that 'won' 55% of the time could turn very wealthy, very quickly. Winning 2/3 of the time would be a model worth billions of dollars. Jul 20 '18 at 16:57
• 1647 trades over 147 years is irrelevant in terms of commissions. What is relevant is the average gain per winning trade and loss per losing trade. Jul 20 '18 at 17:20

The big trick to robo-trading the market is price change velocity. Obviously your algorithm is conceptually sound. Buy low, sell higher if the price appears to be falling. How frequently does this script run? Monthly? Weekly? Nightly? Every 10 mins? Every minute? When do you look at the change to the price movement? What would be a sufficiently appreciated price for you to be willing to sell? How fast would the price have to have fallen from there for you to actually execute a sale? What if the price falls below your cost, do you average down or do you get out?

You can backtest all you want using daily closing prices, but life and the market, are WAY different in real time. There are certainly arguments to be made that today's market simply isn't sufficiently similar to the market in the 60s for that backtesting to even be valid anyway. But I think the biggest issue with your method is simply that it ignores the real time aspect of the real live market. Your low resolution historical data set has very little relation to the actual market tomorrow.

Macro averages and low resolution historical data sets don't sufficiently prepare you for day to day reality. Also, notwithstanding the fact that markets evolve over time negating even high resolution data of several decades ago and you're not accounting for bid ask spreads.

If you think your algorithm works, let it run. Set up a test server, collect live market data, and let it run for the next couple months.

Just winning about 70% of the time isn't sufficient, if the average win results in a \$1 gain while the average loss results in a \$5 loss, for example. Nor are you factoring in trading costs, as far as I can see. Additionally, you don't seem to be taking into account that you can't buy or sell at your spot prices. If the stock closes at \$100, down from \$120, you might not be able to sell it for \$100. You might only get \$80 for that stock, for example.

I'm not saying your strategy won't work, only that I think you aren't considering enough at the moment.

To repeat what @ChrisInEdmonton said, there's not enough information here to answer your question. In addition, it's lacking adequate parameters to be accurate.

The size of the average gain per winning trade and average loss per losing trade has to be factored in. While commissions should be factored in, they're not going to be significant given that number of trades over 147 years, well, at least based on commission rates over the past 25 years or so.

You also need to consider the duration of losing trades. It's great if you have a prolonged win streak but if you enter a multi year losing streak, you'll bail and miss out on the potential of long term gains, assuming it's a winning system.

If you're using closing price for the test, where the security opens the next morning is a question mark. Maybe you get more, maybe you get less but given that the market falls about 3 times faster than it rises. this might also be skewing the results in your favor.

You can't test effectively over rolling 10 year periods. It has to be done continuously over daily data otherwise potential draw downs may be excluded (think Brexit and other short term violent corrections). Looking at monthly data may exclude them.

Your results appear to be a starting point but what you have so far is by no means conclusive. It needs more refining.