Q:

Momentum Investing Experiment and Question

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

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

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.

A:

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.  

