OPEN-SOURCE SCRIPT
RSI HTF Hardcoded (A/B Presets) + Regimes [CHE]

RSI HTF Hardcoded (A/B Presets) + Regimes — Higher-timeframe RSI emulation with acceptance-based regime filter and on-chart diagnostics
Summary
This indicator emulates a higher-timeframe RSI on the current chart by resolving hardcoded “HTF-like” lengths from a time-bucket mapping, avoiding cross-timeframe requests. It computes RSI on a resolved length, smooths it with a resolved moving average, and derives a histogram-style difference (RSI minus its smoother). A four-state regime classifier is gated by a dead-band and an acceptance filter requiring consecutive bars before a regime is considered valid. An on-chart table reports the active preset, resolved mapping tag, resolved lengths, and the current filtered regime.
Pine version: v6
Overlay: false
Primary outputs: RSI line, SMA(RSI) line, RSI–SMA histogram columns, reference levels (30/50/70), regime-change alert, info table
Motivation
Cross-timeframe RSI implementations often rely on `request.security`, which can introduce repaint pathways and additional update latency. This design uses deterministic, on-series computation: it infers a coarse target bucket (or uses a forced bucket) and resolves lengths accordingly. The dead-band reduces noise at the decision boundaries (around RSI 50 and around the RSI–SMA difference), while the acceptance filter suppresses rapid flip-flops by requiring sustained agreement across bars.
Differences
Baseline: Standard RSI with a user-selected length on the same timeframe, or HTF RSI via cross-timeframe requests.
Key differences:
Hardcoded preset families and a bucket-based mapping to resolve “HTF-like” lengths on the current chart.
No `request.security`; all calculations run on the chart’s own series.
Regime classification uses two independent signals (RSI relative to 50 and RSI–SMA difference), gated by a configurable dead-band and an acceptance counter.
Always-on diagnostics via a persistent table (optional), showing preset, mapping tag, resolved lengths, and filtered regime.
Practical effect: The oscillator behaves like a slower, higher-timeframe variant with more stable regime transitions, at the cost of delayed recognition around sharp turns (by design).
How it works
1. Bucket selection: The script derives a coarse “target bucket” from the chart timeframe (Auto) or uses a user-forced bucket.
2. Length resolution: A chosen preset defines base lengths (RSI length and smoothing length). A bucket/timeframe mapping resolves a multiplier, producing final lengths used for RSI and smoothing.
3. Oscillator construction: RSI is computed on the resolved RSI length. A moving average of RSI is computed on the resolved smoothing length. The difference (RSI minus its smoother) is used as the histogram series.
4. Regime classification: Four regimes are defined from:
RSI relative to 50 (bullish above, bearish below), with a dead-band around 50
Difference relative to 0 (positive/negative), with a dead-band around 0
These two axes produce strong/weak bull and bear states, plus a neutral state when inside the dead-band(s).
5. Acceptance filter: The raw regime must persist for `n` consecutive bars before it becomes the filtered regime. The alert triggers when the filtered regime changes.
6. Diagnostics and visualization: Histogram columns change shade based on sign and whether the difference is rising/falling. The table displays preset, mapping tag, resolved lengths, and the filtered regime description.
Parameter Guide
Source — Input series for RSI — Default: Close — Smoother sources reduce noise but add lag.
Preset — Base lengths family — Default: A(14/14) — Switch presets to change RSI and smoothing responsiveness.
Target Bucket — Auto or forced bucket — Default: Auto — Force a bucket to lock behavior across chart timeframe changes.
Table X / Table Y — Table anchor — Default: right / top — Move to avoid covering content.
Table Size — Table text size — Default: normal — Increase for presentations, decrease for dense layouts.
Dark Mode — Table theme — Default: enabled — Match chart background for readability.
Show Table — Toggle diagnostics table — Default: enabled — Disable for a cleaner pane.
Epsilon (dead-band) — Noise gate for decisions — Default: 1.0 — Raise to reduce flips near boundaries; lower to react faster.
Acceptance bars (n) — Bars required to confirm a regime — Default: 3 — Higher reduces whipsaw; lower increases reactivity.
Reading
Histogram (RSI–SMA):
Above zero indicates RSI is above its smoother (positive momentum bias).
Below zero indicates RSI is below its smoother (negative momentum bias).
Darker/lighter shading indicates whether the difference is increasing or decreasing versus the previous bar.
RSI vs SMA(RSI):
RSI’s position relative to 50 provides broad directional bias.
RSI’s position relative to its smoother provides momentum confirmation/contra-signal.
Regimes:
Strong bull: RSI meaningfully above 50 and difference meaningfully above 0.
Weak bull: RSI above 50 but difference below 0 (pullback/transition).
Strong bear: RSI meaningfully below 50 and difference meaningfully below 0.
Weak bear: RSI below 50 but difference above 0 (pullback/transition).
Neutral: inside the dead-band(s).
Table:
Use it to validate the active preset, the mapping tag, the resolved lengths, and the filtered regime output.
Workflows
Trend confirmation:
Favor long bias when strong bull is active; favor short bias when strong bear is active.
Treat weak regimes as pullback/transition context rather than immediate reversals, especially with higher acceptance.
Structure + oscillator:
Combine regimes with swing structure, breakouts, or a baseline trend filter to avoid trading against dominant structure.
Use regime change alerts as a “state change” notification, not as a standalone entry.
Multi-asset consistency:
The bucket mapping helps keep a consistent “feel” across different chart timeframes without relying on external timeframe series.
Behavior/Constraints
Intrabar behavior:
No cross-timeframe requests are used; values can still evolve on the live bar and settle at close depending on your chart/update timing.
Warm-up requirements:
Large resolved lengths require sufficient history to seed RSI and smoothing. Expect a warm-up period after loading or switching symbols/timeframes.
Latency by design:
Dead-band and acceptance filtering reduce noise but can delay regime changes during sharp reversals.
Chart types:
Intended for standard time-based charts. Non-time-based or synthetic chart types (e.g., Heikin-Ashi, Renko, Kagi, Point-and-Figure, Range) can distort oscillator behavior and regime stability.
Tuning
Too many flips near decision boundaries:
Increase Epsilon and/or increase Acceptance bars.
Too sluggish in clean trends:
Reduce Acceptance bars by one, or choose a faster preset (shorter base lengths).
Too sensitive on lower timeframes:
Choose a slower preset (longer base lengths) or force a higher Target Bucket.
Want less clutter:
Disable the table and keep only the alert + plots you need.
What it is/isn’t
This indicator is a regime and visualization layer for RSI using higher-timeframe emulation and stability gates. It is not a complete trading system and does not provide position sizing, risk management, or execution rules. Use it alongside structure, liquidity/volatility context, and protective risk controls.
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.
Best regards and happy trading
Chervolino.
Summary
This indicator emulates a higher-timeframe RSI on the current chart by resolving hardcoded “HTF-like” lengths from a time-bucket mapping, avoiding cross-timeframe requests. It computes RSI on a resolved length, smooths it with a resolved moving average, and derives a histogram-style difference (RSI minus its smoother). A four-state regime classifier is gated by a dead-band and an acceptance filter requiring consecutive bars before a regime is considered valid. An on-chart table reports the active preset, resolved mapping tag, resolved lengths, and the current filtered regime.
Pine version: v6
Overlay: false
Primary outputs: RSI line, SMA(RSI) line, RSI–SMA histogram columns, reference levels (30/50/70), regime-change alert, info table
Motivation
Cross-timeframe RSI implementations often rely on `request.security`, which can introduce repaint pathways and additional update latency. This design uses deterministic, on-series computation: it infers a coarse target bucket (or uses a forced bucket) and resolves lengths accordingly. The dead-band reduces noise at the decision boundaries (around RSI 50 and around the RSI–SMA difference), while the acceptance filter suppresses rapid flip-flops by requiring sustained agreement across bars.
Differences
Baseline: Standard RSI with a user-selected length on the same timeframe, or HTF RSI via cross-timeframe requests.
Key differences:
Hardcoded preset families and a bucket-based mapping to resolve “HTF-like” lengths on the current chart.
No `request.security`; all calculations run on the chart’s own series.
Regime classification uses two independent signals (RSI relative to 50 and RSI–SMA difference), gated by a configurable dead-band and an acceptance counter.
Always-on diagnostics via a persistent table (optional), showing preset, mapping tag, resolved lengths, and filtered regime.
Practical effect: The oscillator behaves like a slower, higher-timeframe variant with more stable regime transitions, at the cost of delayed recognition around sharp turns (by design).
How it works
1. Bucket selection: The script derives a coarse “target bucket” from the chart timeframe (Auto) or uses a user-forced bucket.
2. Length resolution: A chosen preset defines base lengths (RSI length and smoothing length). A bucket/timeframe mapping resolves a multiplier, producing final lengths used for RSI and smoothing.
3. Oscillator construction: RSI is computed on the resolved RSI length. A moving average of RSI is computed on the resolved smoothing length. The difference (RSI minus its smoother) is used as the histogram series.
4. Regime classification: Four regimes are defined from:
RSI relative to 50 (bullish above, bearish below), with a dead-band around 50
Difference relative to 0 (positive/negative), with a dead-band around 0
These two axes produce strong/weak bull and bear states, plus a neutral state when inside the dead-band(s).
5. Acceptance filter: The raw regime must persist for `n` consecutive bars before it becomes the filtered regime. The alert triggers when the filtered regime changes.
6. Diagnostics and visualization: Histogram columns change shade based on sign and whether the difference is rising/falling. The table displays preset, mapping tag, resolved lengths, and the filtered regime description.
Parameter Guide
Source — Input series for RSI — Default: Close — Smoother sources reduce noise but add lag.
Preset — Base lengths family — Default: A(14/14) — Switch presets to change RSI and smoothing responsiveness.
Target Bucket — Auto or forced bucket — Default: Auto — Force a bucket to lock behavior across chart timeframe changes.
Table X / Table Y — Table anchor — Default: right / top — Move to avoid covering content.
Table Size — Table text size — Default: normal — Increase for presentations, decrease for dense layouts.
Dark Mode — Table theme — Default: enabled — Match chart background for readability.
Show Table — Toggle diagnostics table — Default: enabled — Disable for a cleaner pane.
Epsilon (dead-band) — Noise gate for decisions — Default: 1.0 — Raise to reduce flips near boundaries; lower to react faster.
Acceptance bars (n) — Bars required to confirm a regime — Default: 3 — Higher reduces whipsaw; lower increases reactivity.
Reading
Histogram (RSI–SMA):
Above zero indicates RSI is above its smoother (positive momentum bias).
Below zero indicates RSI is below its smoother (negative momentum bias).
Darker/lighter shading indicates whether the difference is increasing or decreasing versus the previous bar.
RSI vs SMA(RSI):
RSI’s position relative to 50 provides broad directional bias.
RSI’s position relative to its smoother provides momentum confirmation/contra-signal.
Regimes:
Strong bull: RSI meaningfully above 50 and difference meaningfully above 0.
Weak bull: RSI above 50 but difference below 0 (pullback/transition).
Strong bear: RSI meaningfully below 50 and difference meaningfully below 0.
Weak bear: RSI below 50 but difference above 0 (pullback/transition).
Neutral: inside the dead-band(s).
Table:
Use it to validate the active preset, the mapping tag, the resolved lengths, and the filtered regime output.
Workflows
Trend confirmation:
Favor long bias when strong bull is active; favor short bias when strong bear is active.
Treat weak regimes as pullback/transition context rather than immediate reversals, especially with higher acceptance.
Structure + oscillator:
Combine regimes with swing structure, breakouts, or a baseline trend filter to avoid trading against dominant structure.
Use regime change alerts as a “state change” notification, not as a standalone entry.
Multi-asset consistency:
The bucket mapping helps keep a consistent “feel” across different chart timeframes without relying on external timeframe series.
Behavior/Constraints
Intrabar behavior:
No cross-timeframe requests are used; values can still evolve on the live bar and settle at close depending on your chart/update timing.
Warm-up requirements:
Large resolved lengths require sufficient history to seed RSI and smoothing. Expect a warm-up period after loading or switching symbols/timeframes.
Latency by design:
Dead-band and acceptance filtering reduce noise but can delay regime changes during sharp reversals.
Chart types:
Intended for standard time-based charts. Non-time-based or synthetic chart types (e.g., Heikin-Ashi, Renko, Kagi, Point-and-Figure, Range) can distort oscillator behavior and regime stability.
Tuning
Too many flips near decision boundaries:
Increase Epsilon and/or increase Acceptance bars.
Too sluggish in clean trends:
Reduce Acceptance bars by one, or choose a faster preset (shorter base lengths).
Too sensitive on lower timeframes:
Choose a slower preset (longer base lengths) or force a higher Target Bucket.
Want less clutter:
Disable the table and keep only the alert + plots you need.
What it is/isn’t
This indicator is a regime and visualization layer for RSI using higher-timeframe emulation and stability gates. It is not a complete trading system and does not provide position sizing, risk management, or execution rules. Use it alongside structure, liquidity/volatility context, and protective risk controls.
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.
Best regards and happy trading
Chervolino.
Skrip sumber terbuka
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Penafian
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Skrip sumber terbuka
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Penafian
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.