OPEN-SOURCE SCRIPT
업데이트됨

MAD RSI

133
MAD RSI ~ by GForge

An adaptive trend-following indicator that combines RSI momentum with Median Absolute Deviation (MAD) volatility bands to identify trend direction, gauge regime strength, and generate entry/exit signals.

Core Concept

Most band-based indicators use Standard Deviation to measure volatility. The problem is that StdDev is highly sensitive to outlier candles — a single spike from news, earnings, or liquidation cascades can blow out the bands and distort signals. This indicator replaces StdDev with Median Absolute Deviation (MAD), a statistically robust volatility measure that resists outliers while still tracking genuine changes in market volatility. The result is more stable bands that better represent the true trading range.

RSI-Adaptive Mechanism

A smoothed RSI is calculated and used to dynamically scale the band width. The logic works as follows: when RSI is near 50 (neutral/indecisive), the bands stay at their base width. As RSI moves further from 50 in either direction — indicating stronger bullish or bearish momentum — the bands widen proportionally. This creates a self-adjusting system: during strong trends the bands expand to avoid premature exits, and during choppy consolidation they contract to keep signals responsive.

The RSI smoothing parameter applies an EMA on top of the raw RSI to control how quickly the adaptive multiplier responds. A low smoothing value makes the bands react quickly to momentum shifts. A higher value smooths out the adaptation, which can reduce whipsaws in noisy conditions.

Oscillator & Signal Logic

The indicator computes a Basis line (Simple Moving Average) and places the adaptive MAD bands above and below it. Price position within these bands is then normalized into an oscillator ranging from 0 to 100, where 0 means price is at the lower band, 50 means price is at the basis, and 100 means price is at the upper band.
Signals are generated when this oscillator crosses key thresholds:

A long signal fires when the oscillator crosses above the Long Threshold, indicating price has moved convincingly into the upper portion of the adaptive channel.

A short/exit signal fires when the oscillator crosses below the Short Threshold, indicating momentum has weakened and price is falling back within the channel.

The thresholds are independently configurable. For example, setting a Long Threshold of 80 means you require price to push well above the midpoint before entering, while a Short Threshold of 30 means you exit relatively early before price reaches neutral. This asymmetry can be tuned for different risk appetites — tighter thresholds produce more signals with smaller moves, wider thresholds produce fewer signals but filter out more noise.

Key Parameters

Source — the price input for all calculations. Close is standard, but hl2, hlc3, or ohlc4 can provide smoother behavior on volatile instruments.

RSI Length — controls the RSI lookback period. Longer values produce a smoother RSI that changes the adaptive multiplier gradually. Shorter values make it more reactive.

RSI Smoothing — additional EMA smoothing applied to the RSI before it feeds into the adaptive multiplier. Set to 1 for no extra smoothing.

Basis Length — the SMA period for the center line of the channel. This is the trend anchor. Longer values track slower trends, shorter values hug price more closely.

MAD Length — lookback for the Median Absolute Deviation calculation. Controls how many bars contribute to the volatility estimate. Longer values produce more stable bands, shorter values adapt faster.

Volatility Multiplier — the base scaling factor for band width before RSI adaptation is applied. Higher values widen the bands and reduce signal frequency. Lower values tighten them and increase signal frequency.

Visuals

A gradient cloud beneath price provides an at-a-glance read of trend regime and strength. Bar colors reflect the oscillator position. Signal markers appear as diamonds above and below bars.
Usage Notes


This is a tool to assist your analysis, not a standalone trading system. Always apply your own risk management and confirm signals with additional context.

Past performance does not guarantee future results.

Default settings are a starting point — optimize for your specific instrument, timeframe, and trading style.

The MAD calculation is particularly well-suited for instruments prone to sudden spikes or gap moves where Standard Deviation-based indicators tend to produce erratic signals.

Developed by GForge
릴리즈 노트
/

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.