I've been struggling for quite a while to find an appropriate formula for finding peaks and troughs. I find 'swing highs' and 'swing lows' based on some arbitrary look-back distance to be a bit too crude. It misses the heart of the subject, and adds an extra layer of constraint I don't like. I did find a paper online, titled "A Peak-Trough Detection Algorithm Based on Momentum," which was interesting, but ultimately not what I wanted. Most of the peak-trough detection algorithms I found dealt with continuous functions -- which made working with stock prices impossible. Empirically, I know the algorithm had to have some volatility component -- and I wanted as little look back as possible. I found an algorithm online (can't find the source) that I modified that worked fairly well. Basically, using a 'delta' function, if your closing price was higher than your last min/max by delta, you locked that min/max as a trough/peak. I chose my delta value to be a function of the ATR. I also allowed peaks and troughs that were 'close' to be merged into a singular peak/trough entity by only keeping the more prominent peak/trough. But even this missed the subtleties. It helped recognize that in times of less volatility, the peaks and troughs were not as pronounced as those in more volatile periods -- but it still missed quite a few. I could sum the issue up nicely: without some sort of continuous representation, it was difficult to find peaks and troughs. Then it hit me like a ton of bricks: a moving average is a continuous representation of price. Durh. Furthermore, price tends to oscillate around fast moving averages. I quickly whipped up an algorithm. Basically, when price crosses above the 10DMA, I start recording highs. When it crosses back below, I take the max high and use that as my peak. Same for troughs -- when price crosses below, I start recording and stop when price crosses above again. The nice thing about this algorithm is that it solves the volatility issue on its own! The 10DMA is adaptive to the price volatility environment! Anyway, just thought I would share the simple, yet effective method for identifying peaks and troughs for any of you out there struggling to find a good algorithm.