OPEN-SOURCE SCRIPT

Quantum Flux Bands [JOAT]

4 277
Quantum Flux Bands [JOAT]

Quantum Flux Bands is an institutional-style regime detector. It stationarizes the price series via Fixed-Window Fractional Differentiation (FFD), runs a classical CUSUM change-point test on the stationarized stream, and draws a baseline that snaps to a new price level on every confirmed regime shift. Around the baseline, three percentile envelopes (50%, 68%, 90%) are drawn and modulated by a windowed Shannon entropy estimator so the bands narrow in low-noise regimes and widen in high-noise regimes.

istantanea

What makes it different
  • Most regime filters hard-code a differentiation order (typically the first difference). FFD takes a real-valued differentiation order d between 0 and 1, retaining long-memory while making the series statistically stationary. This script chooses d adaptively from a rolling Hurst estimate so it responds to the market's persistence regime instead of being a fixed magic number.
  • The CUSUM trigger is fed by FFD-stationarized values, not raw returns. This reduces baseline whipsaws in trending markets that violate stationarity assumptions of classical CUSUM.
  • The bands are entropy-weighted. When the local windowed Shannon entropy is high (low signal-to-noise) the bands expand. When entropy is low (clean regime) they contract. The bands lock at the moment of a confirmed regime shift so they describe the regime under which the baseline was established.


How it works
  1. A two-point Hurst estimator (rescaled-range over short and long windows) drives an adaptive differentiation order d in the range 0.30 to 0.90.
  2. FFD weights are recomputed only when d drifts by more than 0.05 from its cached value. Caching keeps per-bar work near zero.
  3. FFD weights are applied to a sliding window of close prices to produce a stationarized series.
  4. Classical CUSUM tracks cumulative positive and negative deviations of the stationarized series from a running baseline reference, with user-configurable drift and threshold parameters.
  5. When CUSUM exceeds the threshold, the baseline snaps to the current close and the trend state is set to bull or bear.
  6. Inner, mid, and outer envelopes are drawn from percentile_linear_interpolation of the absolute distance between close and baseline, multiplied by an entropy modulator.
  7. A bull probability is computed from the Abramowitz and Stegun standard-normal CDF on the signed band-distance and surfaced as a numeric label.


Reading the chart
  • Baseline line tinted purple in bull regimes, cyan in bear regimes, muted in neutral.
  • Six percentile band lines (upper and lower inner, mid, outer) with three pairs of atmospheric gradient fills calibrated so candles remain readable through every layer.
  • Optional iridescent candle recolor scales tint by signed regime score.
  • A probability label at the right edge of the chart shows the live bull probability.
  • Seven right-edge price labels, one per envelope level plus baseline, each sit at their own price.
  • Regime-shift timeline labels record every confirmed regime change with its baseline price and bull probability at the time of the shift.
  • A 21-segment vertical strength gauge at the right edge maps the continuous regime strength score onto a bull / bear / neutral scale, with a dashed sight-line drawing the gauge level back into the chart.
  • A short forward probability cone: two dashed segments at outer band levels with opacity scaled by class probability.


Signals
  • Bull / bear regime entry (CUSUM trigger with direction)
  • Outer band touch
  • Outer band rejection (wick pierces the outer band but the body closes back inside)
  • Baseline reclaim (close re-crosses the baseline)

All gated on barstate.isconfirmed or barstate.ishistory. No future references. No lookahead_on.

Inputs
  • Fractional Differentiation: FFD window length.
  • CUSUM: volatility period, drift parameter, threshold parameter.
  • Regime: Hurst short / long lookbacks, entropy window / bins / z-score length.
  • Bands: percentile lookback.
  • Visual: bullish, bearish, quantum purple, quantum cyan colors. Band visibility toggles. Iridescent candles. Regime pulse. Probability label.
  • Labels: right-edge level labels, regime timeline (offset off candle wicks by ATR), baseline reclaim markers (direction-sensitive Y offset, configurable minimum-bar spacing), band touch and rejection labels (configurable minimum-bar spacing per type), strength gauge, sight-line needle, probability cone, FFD memory label, entropy state strip.
  • Dashboard: position, size.


How traders use this
  • Mean-reversion fades from outer-band touches inside a stable regime (Hurst mean-reverting, low entropy z) are statistically supported setups.
  • Regime-shift entries: when the baseline snaps and the trend turns, the first inner-band retest is a higher-quality continuation entry than chasing the breakout bar.
  • Probability filter: use the bull probability label as a confidence multiplier for other systems. Below 30% or above 70% are the actionable zones.
  • Entropy context: high entropy z (band-multiplier expanded) is a low conviction, wider stops warning. Low entropy z (bands tight) is a high conviction, tighter stops green light.


Limitations
  • Fractional differentiation is a smoothing and filtering tool. It cannot create information that is not already in the price series.
  • CUSUM, like any change-point detector, lags real-time tops and bottoms. It is calibrated to balance whipsaw against responsiveness.
  • The two-point Hurst estimator is a fast approximation. For long-horizon classification it agrees with the full R/S statistic. For very short windows it is noisier.
  • Past regime persistence does not guarantee future regime persistence.


Compatibility
Pine Script v6 open-source indicator. Any symbol, any timeframe (longer timeframes give the FFD window more meaningful history). No external request.security calls. Non-repainting: regime shifts are committed on confirmed bars and baseline values are not retroactively rewritten.

Defaults
Mint and red bullish / bearish defaults. Purple and cyan quantum accents. Top-right medium dashboard. All on-chart visualizations on. Increase the FFD window for very high timeframes (daily and above) and decrease the percentile lookback for fast intraday charts.

Credits
  • Fractional differentiation methodology popularized by López de Prado, Advances in Financial Machine Learning (2018).
  • CUSUM change-point test as published by E. S. Page, Biometrika (1954).
  • Standard-normal CDF approximation per Abramowitz and Stegun (1964).

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.