OPEN-SOURCE SCRIPT

SuperTrend MA

197
After building SuperBands, I kept thinking about what happens at the midpoint between those two volatility-adaptive envelopes. The upper and lower bands are both trailing price based on ATR and EMA smoothing, but they're operating independently in opposite directions. Taking their average seemed like it might produce an interesting centerline that adapts to volatility in a way that regular moving averages don't. Turns out it does, and that's what this indicator is.

The core concept is straightforward. Instead of plotting the upper and lower SuperBands separately, this calculates both of them internally, averages their values, and then applies an additional smoothing pass with EMA to create a single centerline. That centerline sits roughly in the middle of where the bands would be, but because it's derived from ATR-offset trailing stops rather than direct price smoothing, it behaves differently than a standard moving average of the same length. During trending periods, the centerline tracks closer to price because one of the underlying bands is actively trailing while the other is dormant. During consolidation, both bands compress toward price and the centerline tends to oscillate more with shorter-term movements.

What's interesting is that this acts like a supertrend all by itself with directional behavior baked in. When one of the underlying supertrend waves dominates, meaning price is strongly trending in one direction and only one band is active, you get what feels like a "true" supertrend, whatever that means exactly. The centerline locks into trend-following mode and the color gradient reflects that commitment. You get bright bullish colors during sustained uptrends when the upper band is doing all the work, and strong bearish colors during downtrends when the lower band dominates. But when both bands are active and fighting for control, which happens during consolidation or choppy conditions, the centerline settles into more neutral tones that clearly signal you're in a ranging environment. The colors really do emphasize this behavior and make it visually obvious which regime you're in.

The smoothing parameter controls how aggressively the underlying SuperBand trails adapt to price, which indirectly affects how responsive the centerline is. Lower values make the bands tighter and more reactive, so the centerline follows price action more closely. Higher values create wider bands that only respond to sustained moves, which produces a smoother centerline that filters out more noise. The center smoothing parameter applies a second EMA pass specifically to the averaged midpoint, giving you independent control over how much additional lag you want on the final output versus the raw band average.

What makes this different from just slapping an EMA on price is that the underlying bands are already volatility-aware through their ATR calculations. When volatility spikes, the bands widen and the centerline adjusts its position relative to price based on where those bands settle. A traditional moving average would just smooth over the volatility spike without adjusting its distance from price. This approach incorporates volatility information into the centerline's positioning, which can help it stay relevant during regime changes where fixed-period moving averages tend to lag badly or whipsaw.

The color gradient adds a momentum overlay using the same angle-based calculation from SuperBands. The centerline's rate of change gets normalized by an RMS estimate of its historical movement range, converted to an angle through arctangent scaling, and then mapped to a color gradient. When the centerline is rising, it gradients from neutral toward your chosen bullish color, with brightness increasing as the rate of ascent steepens. When falling, it shifts toward the bearish color with intensity tied to the descent rate. This gives you an immediate visual sense of whether the centerline is accelerating, decelerating, or moving at a stable pace.

Configuration is simpler than SuperBands since you're only dealing with a single output line instead of separate bull and bear envelopes. The length parameter controls the underlying band behavior. ATR period and multiplier determine how much space the bands allocate around price before they trail. Center smoothing adds the extra EMA pass on the averaged midpoint. You can tune these independently to get different characteristics. A tight ATR multiplier with heavy center smoothing creates a smooth line that stays close to price. A wide multiplier with light center smoothing produces a line that swings more freely and adapts faster to directional changes.

From a practical standpoint, this works well as a trend filter or dynamic support and resistance reference. Price above the centerline with bullish coloring suggests a favorable environment for long positions. Price below with bearish coloring indicates the opposite. Crossovers can signal trend changes, though like any moving average system, you'll get whipsaws in choppy conditions. The advantage over traditional MAs is that the volatility adaptation tends to reduce false signals during transitional periods where volatility is expanding but direction hasn't fully committed.

The implementation reuses the entire SuperBands logic, which means all the smoothing and state management for the trailing stops is identical. The only addition is averaging the two band outputs and applying the final EMA pass. The color calculation follows the same RMS-normalized angle approach but applies it to the centerline's delta rather than the individual band deltas. This keeps the coloring consistent with how SuperBands handles momentum visualization while adapting it to a single line instead of dual envelopes.

What this really highlights is that you can derive moving averages from mechanisms other than direct price smoothing. By building the centerline from volatility-adjusted trailing stops, you get adaptive behavior that responds to both price movement and volatility regime without needing separate inputs or complex multi-stage calculations. Whether that adaptation provides a meaningful edge depends on your strategy and market, but it's a fundamentally different approach than the typical fixed-period or adaptive MAs that adjust length based on volatility or momentum indicators.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.