OPEN-SOURCE SCRIPT

StochRSI Context Engine

602
The StochRSI Context Engine is a premium, logic-driven indicator built to provide comprehensive intraday momentum context using multi-timeframe Stochastic RSI analysis. Rather than issuing direct buy or sell signals, the tool is designed to give traders enhanced clarity on trend posture, overbought/oversold conditions, volatility states, and potential momentum reversals. It combines multiple layers of signal processing to deliver an intelligent overview of market conditions in real time.

What it does:

The indicator performs a multi-timeframe evaluation of the Stochastic RSI, sampling values from four customizable timeframes (default: 5m, 15m, 1h, 4h). These values are blended and processed through a series of analytical engines to provide the following:

1. StochRSI Multi-Timeframe Engine
* Computes a smoothed Stochastic RSI value on each selected timeframe.
* Applies user-defined smoothing (SMA, EMA, RMA, or WMA).
* Aggregates these into an average (sRSIavg) for further analysis.


2. Trend and Volatility Engine
* Uses EMA stacking logic (8, 21, 50) to determine directional alignment.
* Calculates linear regression slope for directional bias.
* Assesses volatility using ATR relative to price.
* Derives a trendScore based on EMA alignment, price position, and slope strength.

3. Bias and Slope Analysis
* Measures fast/slow EMA slope differentials to detect bias direction and strength.
* Computes slope deltas and volatility-weighted stacking to score bias conditions.
* Outputs a classification such as strong bullish, moderate bearish, or neutral.

4. Dynamic OB/OS Zone Detection
* Adapts overbought and oversold thresholds based on volatility and trend regime.
* Adjusts the zone boundaries if in a trending or high-volatility environment.

5. Microzone Proximity Detection
* Tracks whether the average StochRSI is approaching key OB/OS thresholds.
* Flags conditions like “Near Overbought,” “Near Oversold,” or “Mid Range.”

6. Velocity and Acceleration Detection
* Measures how quickly StochRSI values are changing.
* Uses delta calculations to gauge the momentum’s thrust or decay.
* Classifies shifts in RSI movement (e.g., flat, slow, fast, or thrusting).

7. Range Expansion / Compression Engine
* Evaluates whether StochRSI values across timeframes are diverging or compressing.
* Identifies regime changes in momentum coherence.

8. Momentum Scoring System
* Calculates a composite score based on bias, slope strength, volatility, and range.
* Labels momentum phases from dormant to full-throttle.

9. Confluence Detection
* Tallies how many of the 4 timeframes are currently overbought or oversold.
* High confluence increases the probability of valid reversal or continuation zones.

10. Support and Resistance Zone Memory
* Tracks and plots previous areas where StochRSI bounced or rejected near zones.
* Stores and updates these zones over time, acting as momentum-based S/R levels.
* Includes a proximity check to cluster zones that are close in value.

11. Divergence Detection Engine
* Detects classic bullish or bearish divergence between price and the aggregated StochRSI.
* Draws lines to show divergence structure and triggers real-time alerts.

12. Smart Background Highlighting
* Shades the background based on whether current StochRSI is in an overbought, oversold, or
neutral zone.

13. Real-Time Dashboard
* Displays trend, bias, confluence count, velocity, divergence state, momentum score, and
more.
* Dynamically updates and is optimized for top-right screen positioning with compact
formatting.

14. Smart Alerts
* Issues alerts for divergence detection and high-confluence reversal conditions.

15. Real-Time Labels on Curves
* Shows the selected timeframes alongside each plotted StochRSI line to clarify source data.



What it’s based on:

* Stochastic RSI as the core input signal, providing normalized momentum across timeframes.
* EMA stacking logic, adapted from institutional trend-following models.
* Volatility normalization using ATR to adapt thresholds in high vs. low volatility environments.
* Slope forecasting using linear regression to infer directional conviction.
* Bias analysis modeled on a composite of EMA distance, alignment, and directional thrust.
* Support/resistance zone memory derived from repeated interaction with dynamic OB/OS thresholds.
* Divergence logic based on localized price and oscillator peaks/troughs.
* Multi-factor confidence scoring, aggregating up to 6 inputs to rate market clarity.



This script is for educational and informational purposes only. It does not generate trade signals or provide financial advice. It is not intended to be used as a standalone system for trading or investment decisions. Use at your own discretion. Always confirm with your broader strategy and risk management practices.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.