OPEN-SOURCE SCRIPT

Kalman Hull Bands For Loop | RakoQuant

406
Kalman Hull Bands For Loop | RakoQuant

RakoQuant | Kalman Hull Bands For Loop is a trend-following breakout + regime tool built to keep you on the right side of the market with clean structure and minimal noise. It combines a Kalman Filter (noise reduction), a Hull Moving Average baseline (responsive trend anchor), and a standard deviation envelope computed via a for-loop (robust rail bands) to define actionable bullish and bearish regimes.

What it does

This indicator builds a dynamic “rail system” around price:

Kalman Filtered Source → reduces measurement noise in the input series.

Hull Baseline (HMA) → fast trend baseline built on the Kalman-filtered source.

Deviation Bands (“Rails”) → upper/lower rails based on a loop-calculated standard deviation.

Regime Breakout Logic → trend regime flips only when price breaks out beyond the rails:

Bullish regime when close crosses above the upper rail

Bearish regime when close crosses below the lower rail

Once a regime is established, the tool highlights the active rail in bright neon and fades the inactive rail (optional), giving you a clear “trend corridor” and a strong visual state.

Key Features
1) Kalman Noise Filtering (R & Q)

The Kalman filter smooths the selected source using:

R (Measurement Noise) – how noisy you assume the observations are

Q (Process Noise) – how quickly the model is allowed to adapt

This helps reduce chop without turning the indicator into a laggy moving average.

2) Hull Baseline (fast + smooth)

The baseline is a Hull Moving Average applied to the Kalman-filtered source:

responsive in trend,

cleaner during transitions,

ideal for breakout regime detection.

3) Deviation Envelope with Two Modes

Deviation rails are calculated using a for-loop standard deviation (population stdev), with two choices:

Residual vs Baseline (default): deviation of (src - baseline)
→ focuses on “distance from fair value” instead of raw price volatility

Raw Source: deviation of the source itself
→ classic volatility envelope behavior

Then bands are formed by:

upper = baseline + mult * sd

lower = baseline - mult * sd

4) Regime Rails + Candle Painting (RakoQuant Neon)

Bull regime: active lower rail plotted in Neon Aqua

Bear regime: active upper rail plotted in Neon Magenta

Candles are painted to match the current state (optional)

Inactive rails can be shown faintly for context.

5) Alerts for Breakouts

Built-in alerts trigger exactly on regime flips:

Bull Breakout (close crosses above upper rail)

Bear Breakout (close crosses below lower rail)

How to Use It
Trend-following approach

Stay with the active regime until a breakout flip occurs.

In bull regime, the lower rail behaves like an adaptive trend support guide.

In bear regime, the upper rail behaves like an adaptive trend resistance guide.

Breakout confirmation

Use the breakout as a confirmation layer with your other confluences:

take longs only after a bull breakout,

take shorts only after a bear breakout,

filter mean-reversion trades by the regime state.

Inputs Summary

Source: select what the model tracks (default: high)

Kalman: R / Q controls smoothing vs responsiveness

Baseline: Hull length

Deviation: loop length, mode (Residual vs Baseline / Raw Source), multiplier

Visuals: candle painting, baseline visibility, inactive rails

Disclaimer

Backtests are based on historical data and are not indicative of future performance.

[RakoQuant Kalman Hull Bands]: ekran görüntüsü

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.