I based this on the idea that if a price is increasing, then the regression line of the last n prices should be positive (depending on the window). It stays in as long as the slope on a long window is positive and gets out when the slope on a short window goes negative. The idea is that the short window is an early warning that the long window is about to go negative. It has a trailing stop loss on the way up. I used sector ETFs for this test.