Cyclic RSI Adaptive Length & Dynamic BandsOverview
A fixed RSI length of 14 is an arbitrary choice — it fits some markets and fights others. Cyclic RSI measures the market's dominant cycle directly from the data and sets the RSI length to half of it, so the read auto-tunes across symbols and timeframes. On top of that it does two more things a plain RSI can't: it draws overbought/oversold bands that adapt to the recent distribution instead of an assumed 70/30, and it applies a cycle-strength gate — because a cyclic oscillator's turns only mean something when a real cycle is actually present. When the spectrum is flat, the pane greys out and the reversal reads are suppressed. It is a momentum/timing tool, not a signal to trade alone.
Why these components are ONE tool (mashup justification)
Each stage exists to fix a specific weakness in the stage before it:
Dominant-cycle measurement. A roofing filter (a high-pass to strip trend plus a smoother to strip noise) isolates the cycle band, and an autocorrelation periodogram over a range of lags produces a power spectrum. Its centre of mass is the dominant cycle; how sharply it peaks is a confidence reading. This is the measurement most cycle work considers more robust than phase-based methods.
Adaptive length. The RSI length is set to half the measured cycle (clamped). This is the whole point — it removes the overfit of a fixed lookback. Because Pine's built-in RSI needs a constant length, the RSI here is summed by hand over the varying half-cycle.
Cyclic smoothing. An optional phasing filter reduces lag so turns are timelier, then a SuperSmoother cleans the line.
Adaptive bands. Overbought and oversold are percentiles of the oscillator's own recent distribution, so the thresholds fit the instrument and regime instead of an assumed 70/30.
Cycle gate + calibration harness. Turns fire only when cycle confidence clears the gate, and a forward harness measures whether those gated turns actually led a move versus the base rate. The cycle read is the picture; the gate says when to trust it; the harness is the proof. Remove any one and you're back to a fixed-length RSI firing overbought/oversold turns in a trend, where they fail most.
How it works
The roofing filter isolates the cycle band. Autocorrelation across lags, projected onto a small set of frequencies, yields a per-period power spectrum smoothed across bars; its centre of mass (over the significant peaks) is the dominant cycle, and its concentration — one sharp peak versus a flat spread — is the confidence. RSI length = half that cycle. The RSI is summed directly over that length, optionally phase-smoothed, then smoothed again. The overbought/oversold bands are recent percentiles of the smoothed oscillator, and a turn off a band is only flagged when confidence clears the gate.
How to use it
Read the oscillator against its adaptive bands, not fixed lines. A turn up off the lower band is a potential reversion long; a turn down off the upper band a potential short — but only trust them when the pane is not greyed (a cycle is present). When the gate is closed, the market is trending or has no clear cycle, and mean-reversion reads are unreliable — that's the tool telling you to stand down, which is exactly when a naive RSI would keep firing losing signals. Gated turns are marked in the pane and, optionally, mirrored on the price chart (up/down triangles) so you can read them without leaving the price. Watch the Edge row: it reports whether gated turns have actually led moves on this instrument. It is never a standalone trigger.
Universal & non-repainting
The source is an input, so it runs on any symbol and timeframe. The oscillator updates live like any RSI; the calibration harness logs and resolves only on closed (confirmed) bars, so its Edge never inflates intrabar. Edge figures are in-sample, close-to-close, with no costs — a study aid, not a backtest. The heaviest part is the periodogram (a bounded lag × frequency scan); if load is slow on very low timeframes, lower the max lag.
Originality
The parts are public: the RSI, roofing filters, autocorrelation-periodogram cycle estimation, half-cycle adaptive RSI length, cyclic smoothing, and distribution-based bands. What's assembled here that isn't sitting on a shelf is the combination: an adaptive-length cyclic RSI wrapped in a spectral-concentration confidence gate that greys the pane and suppresses turns when no cycle is present, plus a forward-calibration harness that scores those gated turns against their base rate. The gate and the harness are this script's own; the rest is credited below. This is an independent Pine v6 implementation — no third-party code is copied verbatim.
Concept credits
Relative Strength Index — J. Welles Wilder.
Roofing filter (high-pass + SuperSmoother), the autocorrelation-periodogram dominant-cycle estimate, and the half-cycle adaptive RSI — John Ehlers (Cycle Analytics for Traders, Rocket Science for Traders).
Cyclic phasing smoother and distribution-based dynamic bands — after Lars von Thienen's cyclic-smoothed RSI (cRSI), from Decoding the Hidden Market Rhythm (whentotrade). That work is licensed Creative Commons Attribution 4.0 International (CC BY 4.0) — creativecommons.org . This script is an independent implementation adapted from that method, with changes (v6 rewrite, spectral-concentration gate, percentile bands, calibration harness); attribution is given as the licence requires.
Disclaimer
Research and educational tool only. Not financial advice, no recommendation, no guarantee of results. Markets are only intermittently cyclic; the cycle estimate lags and gets noisy at regime shifts, which is exactly why the gate exists. Indicators describe past behaviour; they do not predict the future. Trading carries risk of loss. Test out-of-sample and make your own decisions. The author accepts no liability.
อินดิเคเตอร์






















