OPEN-SOURCE SCRIPT

Power RSI Segment Runner [CHE]

224
Power RSI Segment Runner [CHE] — Tracks RSI momentum across higher timeframe segments to detect directional switches for trend confirmation.

Summary
This indicator calculates a running Relative Strength Index adapted to segments defined by changes in a higher timeframe, such as daily closes, providing a smoothed view of momentum within each period. It distinguishes between completed segments, which fix the final RSI value, and ongoing ones, which update in real time with an exponential moving average filter. Directional switches between bullish and bearish momentum trigger visual alerts, including overlay lines and emojis, while a compact table displays current trend strength as a progress bar. This segmented approach reduces noise from intra-period fluctuations, offering clearer signals for trend persistence compared to standard RSI on lower timeframes.

Motivation: Why this design?
Standard RSI often generates erratic signals in choppy markets due to constant recalculation over fixed lookback periods, leading to false reversals that mislead traders during range-bound or volatile phases. By resetting the RSI accumulation at higher timeframe boundaries, this indicator aligns momentum assessment with broader market cycles, capturing sustained directional bias more reliably. It addresses the gap between short-term noise and long-term trends, helping users filter entries without over-relying on absolute overbought or oversold thresholds.

What’s different vs. standard approaches?
- Baseline Reference: Diverges from the classic Wilder RSI, which uses a fixed-length exponential moving average of gains and losses across all bars.
- Architecture Differences:
- Segments momentum resets at higher timeframe changes, isolating calculations per period instead of continuous history.
- Employs persistent sums for ups and downs within segments, with on-the-fly RSI derivation and EMA smoothing.
- Integrates switch detection logic that clears prior visuals on reversal, preventing clutter from outdated alerts.
- Adds overlay projections like horizontal price lines and dynamic percent change trackers for immediate trade context.
- Practical Effect: Charts show discrete RSI endpoints for past segments alongside a curved running trace, making momentum evolution visually intuitive. Switches appear as clean, extendable overlays, reducing alert fatigue and highlighting only confirmed directional shifts, which aids in avoiding whipsaws during minor pullbacks.

How it works (technical)
The indicator begins by detecting changes in the specified higher timeframe, such as a new daily bar, to define segment boundaries. At each boundary, it finalizes the prior segment's RSI by summing positive and negative price changes over that period and derives the value from the ratio of those sums, then applies an exponential moving average for smoothing. Within the active segment, it accumulates ongoing ups and downs from price changes relative to the source, recalculating the running RSI similarly and smoothing it with the same EMA length.

Points for the running RSI are collected into an array starting from the segment's onset, forming a curved polyline once sufficient bars accumulate. Comparisons between the running RSI and the last completed segment's value determine the current direction as long, short, or neutral, with switches triggering deletions of old visuals and creation of new ones: a label at the RSI pane, a vertical dashed line across the RSI range, an emoji positioned via ATR offset on the price chart, a solid horizontal line at the switch price, a dashed line tracking current close, and a midpoint label for percent change from the switch.

Initialization occurs on the first bar by resetting accumulators, and visualization gates behind a minimum bar count since the segment start to avoid early instability. The trend strength table builds vertically with filled cells proportional to the rounded RSI value, colored by direction. All drawing objects update or extend on subsequent bars to reflect live progress.

Parameter Guide
EMA Length — Controls the smoothing applied to the running RSI; higher values increase lag but reduce noise. Default: 10. Trade-offs: Shorter settings heighten sensitivity for fast markets but risk more false switches; longer ones suit trending conditions for stability.

Source — Selects the price data for change calculations, typically close for standard momentum. Default: close. Trade-offs: Open or high/low may emphasize gaps, altering segment intensity.

Segment Timeframe — Defines the higher timeframe for segment resets, like daily for intraday charts. Default: D. Trade-offs: Shorter frames create more frequent but shorter segments; longer ones align with major cycles but delay resets.

Overbought Level — Sets the upper threshold for potential overbought conditions (currently unused in visuals). Default: 70. Trade-offs: Adjust for asset volatility; higher values delay bearish warnings.

Oversold Level — Sets the lower threshold for potential oversold conditions (currently unused in visuals). Default: 30. Trade-offs: Lower values permit deeper dips before signaling bullish potential.

Show Completed Label — Toggles labels at segment ends displaying final RSI. Default: true. Trade-offs: Enables historical review but can crowd charts on dense timeframes.

Plot Running Segment — Enables the curved polyline for live RSI trace. Default: true. Trade-offs: Visualizes intra-segment flow; disable for cleaner panes.

Running RSI as Label — Displays current running RSI as a forward-projected label on the last bar. Default: false. Trade-offs: Useful for quick reads; may overlap in tight scales.

Show Switch Label — Activates RSI pane labels on directional switches. Default: true. Trade-offs: Provides context; omit to minimize pane clutter.

Show Switch Line (RSI) — Draws vertical dashed lines across the RSI range at switches. Default: true. Trade-offs: Marks reversal bars clearly; extends both ways for reference.

Show Solid Overlay Line — Projects a horizontal line from switch price forward. Default: true. Trade-offs: Acts as dynamic support/resistance; wider lines enhance visibility.

Show Dashed Overlay Line — Tracks a dashed line from switch to current close. Default: true. Trade-offs: Shows price deviation; thinner for subtlety.

Show Percent Change Label — Midpoint label tracking percent move from switch. Default: true. Trade-offs: Quantifies progress; centers dynamically.

Show Trend Strength Table — Displays right-side table with direction header and RSI bar. Default: true. Trade-offs: Instant strength gauge; fixed position avoids overlap.

Activate Visualization After N Bars — Delays signals until this many bars into a segment. Default: 3. Trade-offs: Filters immature readings; higher values miss early momentum.

Segment End Label — Color for completed RSI labels. Default: 7E57C2. Trade-offs: Purple tones for finality.

Running RSI — Color for polyline and running elements. Default: yellow. Trade-offs: Bright for live tracking.

Long — Color for bullish switch visuals. Default: green. Trade-offs: Standard for uptrends.

Short — Color for bearish switch visuals. Default: red. Trade-offs: Standard for downtrends.

Solid Line Width — Thickness of horizontal overlay line. Default: 2. Trade-offs: Bolder for emphasis on key levels.

Dashed Line Width — Thickness of tracking and vertical lines. Default: 1. Trade-offs: Finer to avoid dominance.

Reading & Interpretation
Completed segment RSIs appear as static points or labels in purple, indicating the fixed momentum at period close—values drifting toward the upper half suggest building strength, while lower half implies weakness. The yellow curved polyline traces the live smoothed RSI within the current segment, rising for accumulating gains and falling for losses. Directional labels and lines in green or red flag switches: green for running momentum exceeding the prior segment's, signaling potential uptrend continuation; red for the opposite.

The right table's header colors green for long, red for short, or gray for neutral/wait, with filled purple bars scaling from bottom (low RSI) to top (high), topped by the numeric value. Overlay elements project from switch bars: the solid green/red line as a price anchor, dashed tracker showing pullback extent, and percent label quantifying deviation—positive for alignment with direction, negative for counter-moves. Emojis (up arrow for long, down for short) float above/below price via ATR spacing for quick chart scans.

Practical Workflows & Combinations
- Trend Following: Enter long on green switch confirmation after a higher high in structure; filter with table strength above midpoint for conviction. Pair with volume surge for added weight.
- Exits/Stops: Trail stops to the solid overlay line on pullbacks; exit if percent change reverses beyond 2 percent against direction. Use wait bars to confirm without chasing.
- Multi-Asset/Multi-TF: Defaults suit forex/stocks on 1H-4H with daily segments; for crypto, shorten EMA to 5 for volatility. Scale segment TF to weekly for daily charts across indices.
- Combinations: Overlay on EMA clouds for confluence—switch aligning with cloud break strengthens signal. Add volatility filters like ATR bands to debounce in low-volume regimes.

Behavior, Constraints & Performance
Signals confirm on bar close within segments, with running polyline updating live but gated by minimum bars to prevent flicker. Higher timeframe changes may introduce minor repaints on timeframe switches, mitigated by relying on confirmed HTF closes rather than intrabar peeks. Resource limits cap at 500 labels/lines and 50 polylines, pruning old objects on switches to stay efficient; no explicit loops, but array growth ties to segment length—suitable for up to 500-bar histories without lag.

Known limits include delayed visualization in short segments and insensitivity to overbought/oversold levels, as thresholds are inputted but not actively visualized. Gaps in source data reset accumulators prematurely, potentially skewing early RSI.

Sensible Defaults & Quick Tuning
Start with EMA length 10, daily segments, and 3-bar wait for balanced responsiveness on hourly charts. For excessive switches in ranging markets, increase wait bars to 5 or EMA to 14 to dampen noise. If signals lag in trends, drop EMA to 5 and use 1H segments. For stable assets like indices, widen to weekly segments; tune colors for dark/light themes without altering logic.

What this indicator is—and isn’t
This tool serves as a momentum visualization and switch detector layered over price action, aiding trend identification and confirmation in segmented contexts. It is not a standalone trading system, predictive model, or risk calculator—always integrate with broader analysis, position sizing, and stop-loss discipline. View it as an enhancement for discretionary setups, not automated alerts without validation.

Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.

Best regards and happy trading
Chervolino

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.