OPEN-SOURCE SCRIPT

Moving Average Adaptive RSI [BackQuant]

592
Moving Average Adaptive RSI [BackQuant]

What this is
A momentum oscillator that reshapes classic RSI into a zero-centered column plot and makes it adaptive. It builds RSI from two parts:
• A sensitivity window that scans several recent bars to capture the strongest up and down impulses.
• A selectable moving average that smooths those impulses before computing RSI.
The output ranges roughly from −100 to +100 with 0 as the midline, with optional extra smoothing and built-in divergence detection.

How it works

Impulse extraction
• For each bar the script inspects the last rsi_sen bars and collects upward and downward price changes versus the current price.
• It keeps the maximum upward change and maximum downward change from that window, emphasizing true bursts over single-bar noise.

MA-based averaging
• The up and down impulse series are averaged with your chosen MA over rsi_len bars.
• Supported MA types: SMA, EMA, DEMA, WMA, HMA, SMMA (RMA), TEMA.

Zero-centered RSI transform
• RS = UpMA ÷ DownMA, then mapped to a symmetric scale: 100 − 200 ÷ (1 + RS).
• Above 0 implies positive momentum bias. Below 0 implies negative momentum bias.

Optional extra smoothing
• A second smoothing pass can be applied to the final oscillator using smoothing_len and smooth_type. Toggle with “Use Extra Smoothing”.

Visual encoding
• The oscillator is drawn as columns around the zero line with a gradient that intensifies toward extremes.
• Static bands mark 80 to 100 and −80 to −100 for extreme conditions.

Key inputs and what they change
Price Source: input series for momentum.
Calculation Period (rsi_len): primary averaging window on up and down components. Higher = smoother, slower.
Sensitivity (rsi_sen): how many recent bars are scanned to find max impulses. Higher = more responsive to bursts.
Calculation Type (ma_type): MA family that shapes the core behavior. HMA or DEMA is faster, SMA or SMMA is slower.
Smoothing Type and Length: optional second pass to calm noise on the final output.
UI toggles: show or hide the oscillator, candle painting, and extreme bands.

Reading the oscillator
Midline cross up (0): momentum bias turning positive.
Midline cross down (0): momentum bias turning negative.
Positive territory:
– 0 to 40: constructive but not stretched.
– 40 to 80: strong momentum, continuation more likely.
– Above 80: extreme risk of mean reversion grows.
Negative territory: mirror the same levels for the downside.

Divergence detection
The script plots four divergence types using pivot highs and lows on both price and the oscillator. Lookbacks are set by lbL and lbR.
Regular bullish: price lower low, oscillator higher low. Possible downside exhaustion.
Hidden bullish: price higher low, oscillator lower low. Bias to trend continuation up.
Regular bearish: price higher high, oscillator lower high. Possible upside exhaustion.
Hidden bearish: price lower high, oscillator higher high. Bias to trend continuation down.
Labels: ℝ for regular, ℍ for hidden. Green for bullish, red for bearish.

Candle coloring
• Optional bar painting: green when the oscillator is above 0, red when below 0. This is for visual scanning only.

Strengths
• Adaptive sensitivity via a rolling impulse window that responds to genuine bursts.
• Configurable MA core so you can match responsiveness to the instrument.
• Zero-centered scale for simple regime reads with 0 as a clear bias line.
• Built-in regular and hidden divergence mapping.
• Flexible across symbols and timeframes once tuned.

Limitations and cautions
• Trends can remain extended. Treat extremes as context rather than automatic reversal signals.
• Divergence quality depends on pivot lookbacks. Short lookbacks give more signals with more noise. Long lookbacks reduce noise but add lag.
• Double smoothing can delay zero-line transitions. Balance smoothness and timeliness.

Practical usage ideas
Regime filter: only take long setups from your separate method when the oscillator is above 0, shorts when below 0.
Pullback confirmation: in uptrends, look for dips that hold above 0 or turn up from 0 to 40. Reverse for downtrends.
Divergence as a heads-up: wait for a zero-line cross or a price trigger before acting on divergence.
Sensitivity tuning: start with rsi_sen 2 to 5 on faster timeframes, increase slightly on slower charts.

Alerts
MA-A RSI Long: oscillator crosses above 0.
MA-A RSI Short: oscillator crosses below 0.
Use these as bias or timing aids, not standalone trade commands.

Settings quick reference
Calculation: Price Source, Calculation Type, Calculation Period, Sensitivity.
Smoothing: Smoothing Type, Smoothing Length, Use Extra Smoothing.
UI: Show Oscillator, Paint Candles, Show Static High and Low Levels.
Divergences: Pivot Lookback Left and Right, Div Signal Length, Show Detected Divergences.

Final thoughts
This tool reframes RSI by extracting strong short-term impulses and averaging them with a moving-average model of your choice, then presenting a zero-centered output for clear regime reads. Pair it with your structure, risk and execution process, and tune sensitivity and smoothing to the market you trade.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.