If one tests a simple rule, for example "buy when the shiller p/e ratio dips below 15 and sell when it hits 20" then indeed, you would have seen some fantastic results - most obviously in the aftermath of the 2008 financial crisis, when after adjusting for inflation and dividends, you could have bought the S&P500 in Feb 2009 for 887.12 and sold it again in December for 1202.03, realizing a 35% return after inflation).
However, you also would have had the patience and determination to ride out some extremely tough times - you'd be long stocks for the 1987 crash, and completely miss out on the pre-2000 tech bubble, for example). You'd also have to ride out some drawdown that would have wiped out 50% of your capital before the eventual recovery.
In fact, you'd only have placed six trades in about 125 years --
1. Buy in April 1882 and sell in 1898, realizing 2.62% annualized, inflation-adjusted return over 16 years.
2. Buy in March 1907 and sell in 1928, realizing 1.01% annualized and inflation-adjusted over 21 years.
3. Buy in Sept 1931 and sell in 1936, realizing 10.1% annualized over five years (this was a great trade, as you bought in the immediate aftermath of the 1929-1930 crash, and just before the recovery of the early 1930s)
4. Buy in Jan 1937 and sell in 1961, realizing 6.79% annualized over 24 years (another great trade, but you would have had to hold your position over the second world war, which included some terrifying drawdowns).
5. Buy in 1973 and sell in 1992, realizing 2% annualized over 19 years. Again, you'd have to suffer losing over half your capital before you eventually came out on top.
6. Buy in Feb 2009 and sell in December the same year, realizing a 35% return in less than a year (the single greatest trade in the strategy's history, perhaps indicating how thoroughly depressed markets were after the 2008 crash).