OPEN-SOURCE SCRIPT
KAMA SD Bands | RakoQuant

KAMA SD Bands by RakoQuant is an adaptive volatility envelope built around a fully open-source implementation of Kaufman’s Adaptive Moving Average (KAMA).
Instead of measuring raw candle volatility, this tool calculates Standard Deviation on residual structure (price minus KAMA), producing bands that reflect true deviation from adaptive equilibrium.
The result:
* Clean regime shifts
* Intelligent volatility expansion
* Clear bull/bear state transitions
* Strategy-ready signal architecture
This is not a cosmetic overlay — it is a structural framework.
RakoQuant Architecture
1. Adaptive Core (KAMA Engine)
The baseline is a manual implementation of Kaufman’s Adaptive Moving Average:
* Efficiency Ratio (ER) governs responsiveness
* Fast/Slow smoothing parameters define reaction bounds
* Automatically contracts lag in trends
* Smooths aggressively in consolidation
This allows the baseline to behave dynamically across regimes instead of using fixed smoothing.
2. Residual Volatility Bands
Bands are calculated as:
Upper Band = KAMA + (Multiplier × StdDev of Residual) Lower Band = KAMA − (Multiplier × StdDev of Residual)
Where:
Residual = Price − KAMA
This approach measures structural deviation, not random price noise.
Key effect:
* Strong trends → Bands expand progressively
* Range compression → Bands tighten sharply
* Structural breaks → Clean directional triggers
Signal Model (RakoQuant State Logic)
The indicator uses a state-based architecture:
Bullish Regime (1) Confirmed break above upper band.
Bearish Regime (-1) Confirmed break below lower band.
Signal modes:
* Band Break (momentum continuation logic)
* Re-Entry (mean reversion crossover logic)
All signals are designed for:
* Strategy conversion
* Backtesting
* Alert automation
* System stacking
No repainting. No dependency on external libraries.
Visual System
RakoQuant visual configuration includes:
* Multiple professional color palettes
* Optional glow layers
* Trend-sensitive band coloring
* Configurable markers (Labels / Triangles)
* Pine-safe marker sizing
* Optional candle painting
* Toggleable baseline
Every visual element can be disabled for clean strategy integration.
Practical Use Cases
Trend Continuation Use band breaks to identify volatility expansion aligned with adaptive slope.
Volatility Compression Watch for tightening bands as pre-breakout structure forms.
Mean Reversion Use re-entry mode when price returns inside adaptive envelope.
System Development Directly compatible with RakoQuant regime logic architecture.
Design Philosophy
KAMA SD Bands reflects the RakoQuant approach:
* Adaptive > Static
* Structural > Cosmetic
* Deterministic > Black-box
* Backtest-ready > Visual-only
Everything is manual, transparent, and open-source.
Chart Example

Instead of measuring raw candle volatility, this tool calculates Standard Deviation on residual structure (price minus KAMA), producing bands that reflect true deviation from adaptive equilibrium.
The result:
* Clean regime shifts
* Intelligent volatility expansion
* Clear bull/bear state transitions
* Strategy-ready signal architecture
This is not a cosmetic overlay — it is a structural framework.
RakoQuant Architecture
1. Adaptive Core (KAMA Engine)
The baseline is a manual implementation of Kaufman’s Adaptive Moving Average:
* Efficiency Ratio (ER) governs responsiveness
* Fast/Slow smoothing parameters define reaction bounds
* Automatically contracts lag in trends
* Smooths aggressively in consolidation
This allows the baseline to behave dynamically across regimes instead of using fixed smoothing.
2. Residual Volatility Bands
Bands are calculated as:
Upper Band = KAMA + (Multiplier × StdDev of Residual) Lower Band = KAMA − (Multiplier × StdDev of Residual)
Where:
Residual = Price − KAMA
This approach measures structural deviation, not random price noise.
Key effect:
* Strong trends → Bands expand progressively
* Range compression → Bands tighten sharply
* Structural breaks → Clean directional triggers
Signal Model (RakoQuant State Logic)
The indicator uses a state-based architecture:
Bullish Regime (1) Confirmed break above upper band.
Bearish Regime (-1) Confirmed break below lower band.
Signal modes:
* Band Break (momentum continuation logic)
* Re-Entry (mean reversion crossover logic)
All signals are designed for:
* Strategy conversion
* Backtesting
* Alert automation
* System stacking
No repainting. No dependency on external libraries.
Visual System
RakoQuant visual configuration includes:
* Multiple professional color palettes
* Optional glow layers
* Trend-sensitive band coloring
* Configurable markers (Labels / Triangles)
* Pine-safe marker sizing
* Optional candle painting
* Toggleable baseline
Every visual element can be disabled for clean strategy integration.
Practical Use Cases
Trend Continuation Use band breaks to identify volatility expansion aligned with adaptive slope.
Volatility Compression Watch for tightening bands as pre-breakout structure forms.
Mean Reversion Use re-entry mode when price returns inside adaptive envelope.
System Development Directly compatible with RakoQuant regime logic architecture.
Design Philosophy
KAMA SD Bands reflects the RakoQuant approach:
* Adaptive > Static
* Structural > Cosmetic
* Deterministic > Black-box
* Backtest-ready > Visual-only
Everything is manual, transparent, and open-source.
Chart Example
Open-source script
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.
Disclaimer
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.
Open-source script
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.
Disclaimer
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.