SMI Peak/Trough Cycle Average MoveThis indicator is designed to quantify how price typically moves between momentum extremes using the Stochastic Momentum Index (SMI). Instead of simply identifying overbought and oversold conditions, it tracks complete momentum cycles and measures the actual price movement between those turning points to provide a more data-driven expectation of future moves.
At its core, the script calculates the SMI using a smoothed double-EMA approach and plots it in a dedicated indicator pane. Overbought and oversold thresholds are defined at +40 and -40, respectively. While the SMI is inside these zones, the script continuously tracks the most extreme value reached—capturing the lowest point during oversold conditions and the highest point during overbought conditions. However, these extremes are only considered “confirmed” once the SMI exits the respective zone, which helps reduce noise and avoids premature signals.
Once a trough (oversold exit) or peak (overbought exit) is confirmed, the script pairs it with the previous opposite extreme to define a full cycle. It then calculates the price change between those two points—measuring upward moves from trough to peak and downward moves from peak to trough. These moves are recorded in both absolute price terms and percentage terms, allowing the indicator to adapt across different assets and price scales.
To keep the analysis relevant to current market conditions, the script maintains a rolling window of the most recent cycles. By default, it uses the last 10 completed upward and downward cycles separately, rather than averaging over the entire history. This ensures the resulting statistics reflect recent behavior rather than outdated market regimes. From this rolling dataset, it computes average move size, average percentage change, and the magnitude of typical downside moves.
The indicator also visually marks confirmed peaks and troughs directly on the price chart, providing clear context for where each measured cycle begins and ends. In addition, a statistics table is overlaid on the main chart, summarizing total cycle counts along with the rolling averages and sample sizes used in the calculations.
Overall, this tool transforms the SMI from a simple overbought/oversold oscillator into a cycle-based analytical framework. It helps traders move beyond binary signals and instead understand the typical range of price movement associated with momentum swings—making it particularly useful for setting profit targets, managing risk, and evaluating whether a current move is extended relative to recent history.
Pine Script®指标






















