Key takeaways
- Blends four RSI calculations into one composite reading that adapts to trending, ranging, and volatile regimes automatically
- Detects divergences with strength scoring so only high-confidence signals get through, filtering out the noise that plagues basic RSI setups
- Includes momentum burst detection with volume confirmation, useful for catching breakout entries in algo trading systems
- Run it locally with PineTS on Node.js for backtesting or real-time signal generation through the Binance data provider
Loading chart…
What Is the Quantum Momentum Analyzer?
Alright so here’s the thing about RSI. Everyone uses it, everyone knows it, and everyone has been burned by it at least once. You get an overbought signal at 70, you short, and the market just keeps grinding higher for another three weeks. Classic.
The Quantum Momentum Analyzer by JOAT takes a completely different approach. Instead of trusting a single RSI line to tell you something useful, it runs four RSI calculations simultaneously (raw, smoothed, volume-weighted, and multi-layer across three timeframes) and blends them into a composite reading. On top of that, it has regime detection, divergence scanning, momentum burst alerts, and a full dashboard. It’s basically RSI on steroids, with a regime-awareness system bolted on.
I ran this through PineTS on weekly BTCUSDC data and honestly, the regime detection is what caught my attention. It automatically classifies whether you’re in a strong bull, mild bull, neutral, mild bear, strong bear, or extreme bear environment, and adjusts the overbought/oversold levels dynamically. That alone makes it more useful than a plain RSI setup for algo trading.
Running It Locally with PineTS
Running this off TradingView means you can wire it into your own backtesting and signal generation systems. Here’s the setup.
Install PineTS
Grab the package from npm:
npm install pinets
Loading the Pine Script Indicator
PineTS compiles and executes Pine Script v6 natively in Node.js. You feed it the raw .pine source file, point it at a data provider (Binance in this case), and it processes every bar just like TradingView would. All 34 plots from the Quantum Momentum Analyzer come through, including the Quantum RSI line, the multi-layer RSI variants, divergence signals, and momentum histograms.
Batch Execution with pineTS.run()
For a one-shot historical analysis, just load and run:
// PineTS batch execution example template
import { PineTS, Provider } from 'pinets'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const pineScript = readFileSync(join(__dirname, 'source.pine'), 'utf-8')
const pineTS = new PineTS(Provider.Binance, 'BTCUSDC', '1w', 500)
const ctx = await pineTS.run(pineScript)
console.log('Bars processed:', ctx.marketData.length)
console.log('Plots:', Object.keys(ctx.plots).join(', '))
for (const [name, plot] of Object.entries(ctx.plots)) {
const lastPoint = plot.data?.[plot.data.length - 1]
if (lastPoint) {
console.log(` ${name}: last value = ${lastPoint.value}`)
}
}
That pulls 500 weekly BTCUSDC candles and exposes all 34 plots: Quantum RSI composite, fast/slow/ultra-fast layers, divergence markers, histogram values, and the regime state. Enough to build real signal logic from.
Live Streaming with pineTS.stream()
Want live updates? The stream API fires on every new candle from Binance:
// PineTS live streaming example template
import { PineTS, Provider } from 'pinets'
import { readFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const pineScript = readFileSync(join(__dirname, 'source.pine'), 'utf-8')
const pineTS = new PineTS(Provider.Binance, 'BTCUSDC', '1w', 500)
let count = 0
const stream = pineTS.stream(pineScript)
stream.on('data', (ctx) => {
count++
console.log(`[Update ${count}] Bars: ${ctx.marketData.length}, Plots: ${Object.keys(ctx.plots).length}`)
for (const [name, plot] of Object.entries(ctx.plots)) {
const lastPoint = plot.data?.[plot.data.length - 1]
if (lastPoint) {
console.log(` ${name}: ${lastPoint.value}`)
}
}
if (count >= 5) {
console.log('Received 5 updates, stopping stream.')
process.exit(0)
}
})
stream.on('error', (err) => {
console.error('Stream error:', err.message)
process.exit(1)
})
Each callback gives you a fresh context with all plots recalculated. Hook this into your bot and you’re reacting to regime flips and divergence signals in real time, not polling historical data after the fact.
Indicator Properties
Inputs
The indicator has 27 inputs across six groups:
Configuration
| Input | Type | Default | Description |
|---|---|---|---|
| RSI Length | int | 14 | Base period for all RSI calculations |
| RSI Smoothing | int | 3 | EMA smoothing applied to raw RSI values |
| Overbought Level | float | 70 | Static overbought threshold (adjusted dynamically by quantum value) |
| Oversold Level | float | 30 | Static oversold threshold (adjusted dynamically by quantum value) |
| Volume-Weighted RSI | bool | true | Enable volume-adjusted RSI component in the composite |
| Volume Weight Length | int | 20 | SMA period for volume weighting calculation |
Quantum Regime Detection
| Input | Type | Default | Description |
|---|---|---|---|
| Regime Lookback | int | 50 | Period for calculating RSI mean and standard deviation |
| Regime Threshold | float | 5.0 | RSI distance from 50 to trigger regime classification |
| Show Regime Background | bool | true | Color the chart background by regime state |
| Show Quantum Zones | bool | true | Display dynamic support/resistance zones |
| Quantum Sensitivity | int | 3 | Controls the amplitude influence on the Quantum RSI blend (1-5) |
Neural Divergence Detection
| Input | Type | Default | Description |
|---|---|---|---|
| Show Divergences | bool | true | Enable divergence marker plotting |
| Pivot Lookback | int | 5 | Bars to look back for pivot confirmation |
| Max Divergence Bars | int | 50 | Maximum distance between two pivots forming a divergence |
| Show Hidden Divergences | bool | true | Also plot hidden (continuation) divergences |
| Divergence Strength Threshold | float | 0.5 | Minimum strength score required to plot a divergence signal |
Multi-Dimensional Analysis
| Input | Type | Default | Description |
|---|---|---|---|
| Show Multi-Layer RSI | bool | true | Display fast, slow, and ultra-fast RSI layers |
| Fast RSI Length | int | 7 | Short-term RSI period |
| Slow RSI Length | int | 21 | Long-term RSI period |
| Ultra-Fast RSI Length | int | 3 | Very short-term RSI for momentum spikes |
| Show Momentum Vortex | bool | true | Display animated vortex particles around the RSI line |
Visual Effects
| Input | Type | Default | Description |
|---|---|---|---|
| Show Momentum Histogram | bool | true | Display the RSI delta histogram at the centerline |
| Show Dashboard | bool | true | Show the top-right information table |
| Histogram Width | int | 2 | Column width for the momentum histogram |
| Show Glow Effects | bool | true | Add glow to the main Quantum RSI line |
| Show Pulse Animation | bool | true | Subtle pulsing background effect during active regimes |
| Color Scheme | string | Quantum | Visual theme: Quantum, Neon, Plasma, or Monochrome |
Advanced Settings
| Input | Type | Default | Description |
|---|---|---|---|
| Show Momentum Bursts | bool | true | Highlight sudden momentum acceleration events |
| Burst Threshold | float | 3.0 | Minimum acceleration required to trigger a burst signal |
| Show Momentum Flow | bool | true | Draw trailing flow lines behind the RSI |
| Flow Length | int | 10 | Number of bars for the momentum flow trail |
Plots
| Plot Name | Type | Description |
|---|---|---|
| Quantum RSI | Line (width 3) | Main composite RSI blending raw, smoothed, volume-weighted, and quantum-modulated values. Gradient colored by momentum. |
| Fast RSI | Line (width 2) | Short-term RSI (default 7-period), EMA smoothed. Green tint. |
| Slow RSI | Line (width 2) | Long-term RSI (default 21-period), EMA smoothed. Orange tint. |
| Ultra-Fast RSI | Line (width 1) | Very short-term RSI (default 3-period) for catching momentum spikes. Purple tint. |
| Volume-Weighted RSI | Line (width 2) | RSI calculated from volume-weighted price, showing where the money is actually flowing. Yellow. |
| Quantum Overbought | Line | Dynamic overbought level, shifts based on the quantum amplitude value. |
| Quantum Oversold | Line | Dynamic oversold level, same quantum adjustment as overbought. |
| Quantum Momentum | Histogram | RSI delta (fast minus slow) plus quantum offset, plotted as columns around the 50 centerline. |
| Ultra Momentum | Histogram | Ultra-fast RSI rate of change, scaled and plotted as thin columns around 50. |
| Divergence Markers | Shapes | Bull/bear divergences (strong and weak) plus hidden divergences, plotted at pivot locations. |
Alerts
| Alert | Condition |
|---|---|
| Quantum Overbought Entry | Quantum RSI crosses above the dynamic overbought level |
| Quantum Oversold Entry | Quantum RSI crosses below the dynamic oversold level |
| Bullish Divergence | Price makes lower low while Quantum RSI makes higher low |
| Bearish Divergence | Price makes higher high while Quantum RSI makes lower high |
| Bullish Regime Change | Regime state shifts from neutral/bearish to bullish |
| Bearish Regime Change | Regime state shifts from neutral/bullish to bearish |
| Momentum Burst | RSI acceleration exceeds threshold with volume spike (1.5x average) |
| Vortex Activation | Momentum vortex intensity crosses above 1.0 |
| Quantum High State | Quantum amplitude exceeds 0.5 (strong phase alignment) |
| Quantum Low State | Quantum amplitude drops below -0.5 (weak phase alignment) |
Understanding the Indicator
The Multi-Layer RSI Composite
Here’s where JOAT’s approach gets interesting. Instead of picking one RSI period and hoping it works, the indicator runs four independent RSI calculations and merges them. The raw RSI (ta.rsi(close, rsiLength)) gives you the standard 14-period reading. That gets EMA-smoothed with a 3-bar window to knock out noise. A volume-weighted variant uses ta.sma(close * volume, volWeightLength) / ta.sma(volume, volWeightLength) as its source, so bars with heavy volume pull the reading more than thin bars. Then a multi-layer RSI averages three different periods (7, 14, 21) to capture momentum across short, medium, and long cycles.
The final Quantum RSI blends the smoothed RSI with the volume-weighted variant using a “quantum amplitude” factor. I’ll be honest, the “quantum” label is just branding for a sine-wave modulator derived from the timestamp: quantumPhase = (time / 100000) % (2 * math.pi). It creates a cyclical oscillation that shifts how much weight the volume-weighted component gets. The practical effect? The composite RSI reading drifts slightly between favoring smoothed momentum and favoring volume-confirmed momentum, which actually prevents it from getting stuck in one mode.
Regime Detection That Actually Adapts
This is the feature that makes the indicator worth a closer look. The detectQuantumRegime() function classifies the market into seven states: extreme bull (3), strong bull (2), mild bull (1), neutral (0), mild bear (-1), strong bear (-2), and extreme bear (-3). It does this by measuring how far the Quantum RSI has deviated from its 50-bar mean, scaled by its own standard deviation, then modified by volume relative to its average.
When the Quantum RSI sits above 55 (50 plus the default 5.0 threshold) and the z-score deviation is above 1.5, you’re in extreme bull territory. The background shifts to a bright cyan-green tint. Drop below -1.5 deviation on the bearish side and it flips to bright red. The overbought and oversold levels themselves adjust too, via quantumOb = obLevel + quantumValue * 5, so in a strong bullish regime the overbought line pushes higher, making it harder to trigger a premature reversal signal.
That directly solves the classic RSI problem of flagging “overbought” while a strong trend just keeps running.
Divergence Detection with Strength Scoring
JOAT didn’t just slap a basic divergence detector on this. The system uses pivot-based detection on both price and the Quantum RSI, with a configurable lookback (default 5 bars for pivot confirmation) and a maximum distance of 50 bars between the two pivots forming the divergence. But the interesting part is the strength calculation.
Each divergence gets scored using calculateDivergenceStrength(), which blends three factors: price difference (40% weight), RSI difference (40% weight), and volume difference (20% weight). Only divergences exceeding the strength threshold (default 0.5) get plotted. Strong divergences (strength above 1.0) get a bigger label (“BULL DIV” or “BEAR DIV”), while weaker ones get a smaller marker. This filtering is crucial for algo trading because it cuts out the noise divergences that look good on a chart but lead nowhere in practice.
Hidden divergences (continuation signals) are supported too. A hidden bullish divergence fires when price makes a higher low but the Quantum RSI makes a lower low, suggesting the uptrend has more room to run despite the momentum dip.
Using It for Algorithmic Signal Generation
So now that you understand what the indicator is computing, let’s talk about actually using it. I’ve been testing this on weekly BTCUSDC and here’s what works well.
Start with the regime as your filter. Don’t try to catch reversals in an extreme bull or extreme bear regime. Those readings mean momentum is strong and confirmed by volume. Instead, use the regime to decide which signals to act on. In a strong bull regime (regime.current >= 2), only take bullish divergences and momentum bursts in the upward direction. In a ranging/neutral regime (0), the overbought/oversold crossovers become your primary signals.
Momentum burst detection is gold for breakout strategies. A burst fires when the ultra-fast RSI acceleration exceeds the threshold AND volume spikes above 1.5x the 20-bar average. That dual confirmation (momentum + volume) filters out a lot of the fake breakouts you’d get from momentum alone. Wire the “Momentum Burst” alert into your bot and use the regime direction to decide whether to go long or short.
For mean-reversion strategies, watch the delta between the fast RSI (7-period) and slow RSI (21-period). When rsiDelta expands beyond +/-5 in a neutral regime, it tends to snap back. Visually the histogram makes this obvious, but programmatically you want to track rsiFastSmooth - rsiSlowSmooth from the PineTS output.
One approach I’d recommend: use the Quantum RSI crossing 50 as your trend direction filter, the regime state as your confidence level, and the divergence signals as your actual entry triggers. Layer those three together and you have a system that’s significantly more robust than a raw RSI crossover strategy.
Performance Notes
A few things to keep in mind for production use. With 500 max lines, 200 max boxes, and 200 max labels, this is a heavier indicator. Weekly and daily timeframes handle it fine in PineTS, but drop to 1-minute bars with 500 candles and expect slower execution from the divergence detection and vortex particle calculations running on every bar.
One quirk: the “quantum phase” uses time / 100000 as its seed, so the modulation produces different readings depending on your data provider’s timestamp precision. Binance weekly candles handle this fine. Providers with millisecond-precision timestamps will cycle through the phase faster, so your readings won’t exactly match TradingView’s chart.
Five-bar pivot confirmation means a weekly divergence takes over a month to show up. On 4H charts, you’d see signals within about a day. Your stops and position sizes need to account for that delay.
Regime detection needs 50 bars of history to stabilize. On weekly BTCUSDC, that’s roughly a year of data. The default 500-candle fetch gives you plenty of runway, but if you drop the candle count, know that the regime readings will be unreliable for the first stretch.
Important Notes
All 34 plots render correctly in PineTS, as you’d expect from the test run above. The dashboard table comes through as a data structure in the PineTS context rather than a visual table, so parse it from there rather than looking for DOM output.
You’ll need the Binance data provider for the default BTCUSDC pair. Other providers work too, but volume data quality varies, and since this indicator leans heavily on volume weighting, unreliable volume data will degrade the Quantum RSI composite and regime detection accuracy. Stick with exchanges that report real volume.
The glow, pulse, and vortex particle effects don’t translate to anything useful in PineTS. They just show up as extra plot values. Ignore them and pull from the Quantum RSI, regime state, divergence markers, and burst flags.
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © officialjackofalltrades
//@version=6
indicator("Quantum Momentum Analyzer [JOAT]", "QMA [JOAT]", overlay=false, max_lines_count=500, max_boxes_count=200, max_labels_count=200)
// ══════════════════════════════════════════════════════════════════════════════
// QUANTUM MOMENTUM ANALYZER
// Institutional-grade momentum analysis with quantum-inspired visualization
// Features: Multi-dimensional RSI, Quantum regime detection, Neural divergence, Momentum vortex
// ══════════════════════════════════════════════════════════════════════════════
// ─────────────────────────────────────────────────────────────────────────────
// COLOR PALETTE - Quantum Momentum Theme
// ─────────────────────────────────────────────────────────────────────────────
// Define spectral color function from memories
getSpectralColor(frequency) =>
color.from_gradient(frequency, 0, 1, color.blue, color.red)
// Define adaptive color function from memories
getAdaptiveColor() =>
trend = ta.change(close, 20) > 0 ? 1 : -1
color.from_gradient(trend, -1, 1, color.red, color.green)
var color QMA_QUANTUM_CYAN = getSpectralColor(0.5) // Using spectral color function
var color QMA_QUANTUM_PURPLE = getSpectralColor(0.7)
var color QMA_QUANTUM_GREEN = getSpectralColor(0.4)
var color QMA_QUANTUM_ORANGE = getSpectralColor(0.6)
var color QMA_QUANTUM_RED = getSpectralColor(0.8)
var color QMA_QUANTUM_PINK = #ff1493 // Hot pink
var color QMA_NEON_BLUE = #1e90ff // Neon blue
var color QMA_DARK_MATTER = #0a0a0f // Dark matter
var color QMA_NEUTRAL_GRAY = #4a5568 // Neutral gray
var color QMA_WARNING_YELLOW = #ffd700 // Warning gold
// Gradient colors for regimes
var color QMA_EXTREME_BULL = #00ffd5 // Bright cyan-green
var color QMA_STRONG_BULL = #00d4a1 // Strong green
var color QMA_MILD_BULL = #00b389 // Mild green
var color QMA_MILD_BEAR = #e06377 // Mild red
var color QMA_STRONG_BEAR = #d93d64 // Strong red
var color QMA_EXTREME_BEAR = #ff2d55 // Bright red
// Special effect colors
var color QMA_DIVERGENCE_BULL = #00ffea // Bull divergence
var color QMA_DIVERGENCE_BEAR = #ff0080 // Bear divergence
var color QMA_HIDDEN_DIV = #9945ff // Hidden divergence
var color QMA_MOMENTUM_BURST = #ffff00 // Momentum burst
// Zone colors
var color QMA_OB_ZONE = color.new(#ff0040, 85)
var color QMA_OS_ZONE = color.new(#00ffcc, 85)
var color QMA_QUANTUM_ZONE = color.new(#9945ff, 90)
var color QMA_NEUTRAL_ZONE = color.new(#4a5568, 90)
// ─────────────────────────────────────────────────────────────────────────────
// INPUTS
// ─────────────────────────────────────────────────────────────────────────────
string grpRSI = " Configuration"
int rsiLength = input.int(14, "RSI Length", minval=2, maxval=50, group=grpRSI)
int rsiSmoothing = input.int(3, "RSI Smoothing", minval=1, maxval=10, group=grpRSI)
float obLevel = input.float(70, "Overbought Level", minval=60, maxval=90, group=grpRSI)
float osLevel = input.float(30, "Oversold Level", minval=10, maxval=40, group=grpRSI)
bool useVolumeWeight = input.bool(true, "Volume-Weighted RSI", group=grpRSI)
int volWeightLength = input.int(20, "Volume Weight Length", minval=5, maxval=50, group=grpRSI)
string grpRegime = "Quantum Regime Detection"
int regimeLookback = input.int(50, "Regime Lookback", minval=20, maxval=200, group=grpRegime)
float regimeThresh = input.float(5.0, "Regime Threshold", minval=1.0, maxval=20.0, step=0.5, group=grpRegime)
bool showRegimeBG = input.bool(true, "Show Regime Background", group=grpRegime)
bool showQuantumZones = input.bool(true, "Show Quantum Zones", group=grpRegime)
int quantumSensitivity = input.int(3, "Quantum Sensitivity", minval=1, maxval=5, group=grpRegime)
string grpDivergence = "Neural Divergence Detection"
bool showDivergence = input.bool(true, "Show Divergences", group=grpDivergence)
int pivotLookback = input.int(5, "Pivot Lookback", minval=2, maxval=15, group=grpDivergence)
int maxDivBars = input.int(50, "Max Divergence Bars", minval=10, maxval=100, group=grpDivergence)
bool showHiddenDiv = input.bool(true, "Show Hidden Divergences", group=grpDivergence)
float divStrengthThresh = input.float(0.5, "Divergence Strength Threshold", minval=0.1, maxval=2.0, step=0.1, group=grpDivergence)
string grpMultiLayer = "Multi-Dimensional Analysis"
bool showMultiLayer = input.bool(true, "Show Multi-Layer RSI", group=grpMultiLayer)
int fastLength = input.int(7, "Fast RSI Length", minval=2, maxval=20, group=grpMultiLayer)
int slowLength = input.int(21, "Slow RSI Length", minval=10, maxval=50, group=grpMultiLayer)
int ultraFastLength = input.int(3, "Ultra-Fast RSI Length", minval=2, maxval=10, group=grpMultiLayer)
bool showMomentumVortex = input.bool(true, "Show Momentum Vortex", group=grpMultiLayer)
string grpVisual = "Visual Effects"
bool showMomentumBars = input.bool(true, "Show Momentum Histogram", group=grpVisual)
bool showDashboard = input.bool(true, "Show Dashboard", group=grpVisual)
int histogramWidth = input.int(2, "Histogram Width", minval=1, maxval=5, group=grpVisual)
bool showGlowEffect = input.bool(true, "Show Glow Effects", group=grpVisual)
bool showPulseEffect = input.bool(true, "Show Pulse Animation", group=grpVisual)
string colorScheme = input.string("Quantum", "Color Scheme", ["Quantum", "Neon", "Plasma", "Monochrome"], group=grpVisual)
string grpAdvanced = "Advanced Settings"
bool showMomentumBursts = input.bool(true, "Show Momentum Bursts", group=grpAdvanced)
float burstThreshold = input.float(3.0, "Burst Threshold", minval=1.0, maxval=10.0, step=0.5, group=grpAdvanced)
bool showMomentumFlow = input.bool(true, "Show Momentum Flow", group=grpAdvanced)
int flowLength = input.int(10, "Flow Length", minval=5, maxval=30, group=grpAdvanced)
// ─────────────────────────────────────────────────────────────────────────────
// TYPE DEFINITIONS
// ─────────────────────────────────────────────────────────────────────────────
type DivergencePoint
int barIdx
float price
float rsiValue
bool isBullish
bool isHidden
float strength
label marker
line trendLine
type RegimeState
int current
float strength
int duration
float avgRSI
float quantumValue
box zoneBox
type MomentumBurst
int barIdx
float strength
float rsiValue
float volume
box burstBox
label burstLabel
type MomentumVortex
array<float> values
float rotation
float intensity
array<label> particles
type QuantumZone
float upper
float lower
int strength
bool isActive
box zoneBox
line midLine
// ─────────────────────────────────────────────────────────────────────────────
// CORE RSI CALCULATIONS
// ─────────────────────────────────────────────────────────────────────────────
rsiRaw = ta.rsi(close, rsiLength)
rsiSmooth = ta.ema(rsiRaw, rsiSmoothing)
// Volume-weighted RSI
volWeightedRSI = useVolumeWeight ? ta.sma(close * volume, volWeightLength) / ta.sma(volume, volWeightLength) : close
vwRsiRaw = ta.rsi(volWeightedRSI, rsiLength)
vwRsiSmooth = ta.ema(vwRsiRaw, rsiSmoothing)
// Multi-layer RSI
rsiFast = ta.rsi(close, fastLength)
rsiSlow = ta.rsi(close, slowLength)
rsiUltraFast = ta.rsi(close, ultraFastLength)
rsiFastSmooth = ta.ema(rsiFast, rsiSmoothing)
rsiSlowSmooth = ta.ema(rsiSlow, rsiSmoothing)
rsiUltraSmooth = ta.ema(rsiUltraFast, rsiSmoothing)
rsiDelta = rsiFastSmooth - rsiSlowSmooth
rsiMomentum = ta.change(rsiSmooth, 3)
ultraMomentum = ta.change(rsiUltraSmooth, 1)
// Quantum calculations
quantumPhase = (time / 100000) % (2 * math.pi)
quantumAmplitude = math.sin(quantumPhase) * 0.5 + 0.5
quantumRSI = rsiSmooth + (vwRsiSmooth - rsiSmooth) * quantumAmplitude * quantumSensitivity / 5
// Initialize arrays and variables
var array<DivergencePoint> divergences = array.new<DivergencePoint>()
var array<MomentumBurst> bursts = array.new<MomentumBurst>()
var array<QuantumZone> quantumZones = array.new<QuantumZone>()
var MomentumVortex vortex = MomentumVortex.new(array.new<float>(), 0, 0, array.new<label>())
var RegimeState regime = RegimeState.new(0, 0.0, 0, 50.0, 0, na)
var float lastQuantumValue = na
var int burstCount = 0
var float flowDirection = 0
var int regimeSeries = na
// Moved createQuantumZone function definition here
createQuantumZone() =>
if array.size(quantumZones) > 5
oldZone = array.shift(quantumZones)
if not na(oldZone.zoneBox)
box.delete(oldZone.zoneBox)
if not na(oldZone.midLine)
line.delete(oldZone.midLine)
zoneStrength = math.abs(regime.current)
zoneWidth = 20 * zoneStrength
zoneCenter = quantumRSI
QuantumZone newZone = QuantumZone.new(
zoneCenter + zoneWidth/2,
zoneCenter - zoneWidth/2,
zoneStrength,
true,
na,
na
)
array.push(quantumZones, newZone)
// ─────────────────────────────────────────────────────────────────────────────
// QUANTUM REGIME DETECTION
// ─────────────────────────────────────────────────────────────────────────────
rsiAvg = ta.sma(quantumRSI, regimeLookback)
rsiStdDev = ta.stdev(quantumRSI, regimeLookback)
volAvg = ta.sma(volume, regimeLookback)
// Enhanced regime detection with quantum and volume factors
detectQuantumRegime() =>
int newRegime = 0
float strength = 0.0
float qValue = 0.0
float deviation = (quantumRSI - rsiAvg) / math.max(rsiStdDev, 0.1)
float volFactor = volume / math.max(volAvg, 1)
float quantumFactor = math.sin(quantumPhase) * 0.3 + 0.7
float combinedDeviation = deviation * quantumFactor * (1 + (volFactor - 1) * 0.3)
if quantumRSI > 50 + regimeThresh
if combinedDeviation > 1.5
newRegime := 3
strength := math.min(100, combinedDeviation * 33)
qValue := quantumAmplitude
else if combinedDeviation > 0.5
newRegime := 2
strength := math.min(100, combinedDeviation * 50)
qValue := quantumAmplitude * 0.8
else
newRegime := 1
strength := math.min(100, combinedDeviation * 100)
qValue := quantumAmplitude * 0.6
else if quantumRSI < 50 - regimeThresh
if combinedDeviation < -1.5
newRegime := -3
strength := math.min(100, math.abs(combinedDeviation) * 33)
qValue := -quantumAmplitude
else if combinedDeviation < -0.5
newRegime := -2
strength := math.min(100, math.abs(combinedDeviation) * 50)
qValue := -quantumAmplitude * 0.8
else
newRegime := -1
strength := math.min(100, math.abs(combinedDeviation) * 100)
qValue := -quantumAmplitude * 0.6
else
newRegime := 0
strength := math.abs(combinedDeviation) * 20
qValue := 0
[newRegime, strength, qValue]
[newRegime, regimeStrength, quantumValue] = detectQuantumRegime()
if newRegime != regime.current
regime.current := newRegime
regime.duration := 0
// Create quantum zone on regime change
if showQuantumZones
createQuantumZone()
else
regime.duration += 1
regime.strength := regimeStrength
regime.avgRSI := rsiAvg
regime.quantumValue := quantumValue
regimeSeries := regime.current
// ─────────────────────────────────────────────────────────────────────────────
// NEURAL DIVERGENCE DETECTION
// ─────────────────────────────────────────────────────────────────────────────
priceHigh = ta.pivothigh(high, pivotLookback, pivotLookback)
priceLow = ta.pivotlow(low, pivotLookback, pivotLookback)
rsiHigh = ta.pivothigh(quantumRSI, pivotLookback, pivotLookback)
rsiLow = ta.pivotlow(quantumRSI, pivotLookback, pivotLookback)
vwRsiHigh = ta.pivothigh(vwRsiSmooth, pivotLookback, pivotLookback)
vwRsiLow = ta.pivotlow(vwRsiSmooth, pivotLookback, pivotLookback)
var float lastPriceHigh = na
var float lastPriceLow = na
var float lastRsiHigh = na
var float lastRsiLow = na
var float lastVwRsiHigh = na
var float lastVwRsiLow = na
var int lastPriceHighBar = na
var int lastPriceLowBar = na
// Enhanced divergence detection with strength calculation
// Pre-compute ta.sma at global scope for consistency
float volSma20 = ta.sma(volume, 20)
calculateDivergenceStrength(float priceDiff, float rsiDiff, float volDiff) =>
priceStrength = math.abs(priceDiff) / close * 100
rsiStrength = math.abs(rsiDiff)
volStrength = volDiff / nz(volSma20, 1.0)
(priceStrength * 0.4 + rsiStrength * 0.4 + volStrength * 0.2)
// Pre-compute divergence strength at global scope so function runs every bar
float _divStrengthGlobal = calculateDivergenceStrength(0.0, 0.0, 0.0)
if not na(priceHigh)
prevPriceHigh = lastPriceHigh
prevRsiHigh = lastRsiHigh
prevVwRsiHigh = lastVwRsiHigh
prevBar = lastPriceHighBar
lastPriceHigh := priceHigh
lastRsiHigh := quantumRSI[pivotLookback]
lastVwRsiHigh := vwRsiSmooth[pivotLookback]
lastPriceHighBar := bar_index - pivotLookback
if showDivergence and not na(prevPriceHigh) and not na(prevRsiHigh)
barDiff = bar_index - pivotLookback - prevBar
priceDiff = priceHigh - prevPriceHigh
rsiDiff = lastRsiHigh - prevRsiHigh
int prevBarOffset = math.max(0, math.min(bar_index - prevBar, 10000))
volDiff = volume[pivotLookback] - volume[prevBarOffset]
divStrength = calculateDivergenceStrength(priceDiff, rsiDiff, volDiff)
if barDiff <= maxDivBars and barDiff > pivotLookback
// Regular bearish divergence
if priceHigh > prevPriceHigh and lastRsiHigh < prevRsiHigh and divStrength >= divStrengthThresh
DivergencePoint dp = DivergencePoint.new(
bar_index - pivotLookback, priceHigh, lastRsiHigh,
false, false, divStrength, na, na
)
array.push(divergences, dp)
// Hidden bearish divergence
if priceHigh < prevPriceHigh and lastRsiHigh > prevRsiHigh and showHiddenDiv
DivergencePoint dp = DivergencePoint.new(
bar_index - pivotLookback, priceHigh, lastRsiHigh,
false, true, divStrength, na, na
)
array.push(divergences, dp)
if not na(priceLow)
prevPriceLow = lastPriceLow
prevRsiLow = lastRsiLow
prevVwRsiLow = lastVwRsiLow
prevBar = lastPriceLowBar
lastPriceLow := priceLow
lastRsiLow := quantumRSI[pivotLookback]
lastVwRsiLow := vwRsiSmooth[pivotLookback]
lastPriceLowBar := bar_index - pivotLookback
if showDivergence and not na(prevPriceLow) and not na(prevRsiLow)
barDiff = bar_index - pivotLookback - prevBar
priceDiff = prevPriceLow - priceLow
rsiDiff = lastRsiLow - prevRsiLow
int prevBarOffset = math.max(0, math.min(bar_index - prevBar, 10000))
volDiff = volume[pivotLookback] - volume[prevBarOffset]
divStrength = calculateDivergenceStrength(priceDiff, rsiDiff, volDiff)
if barDiff <= maxDivBars and barDiff > pivotLookback
// Regular bullish divergence
if priceLow < prevPriceLow and lastRsiLow > prevRsiLow and divStrength >= divStrengthThresh
DivergencePoint dp = DivergencePoint.new(
bar_index - pivotLookback, priceLow, lastRsiLow,
true, false, divStrength, na, na
)
array.push(divergences, dp)
// Hidden bullish divergence
if priceLow > prevPriceLow and lastRsiLow < prevRsiLow and showHiddenDiv
DivergencePoint dp = DivergencePoint.new(
bar_index - pivotLookback, priceLow, lastRsiLow,
true, true, divStrength, na, na
)
array.push(divergences, dp)
// Cleanup old divergences
if array.size(divergences) > 20
oldDiv = array.shift(divergences)
if not na(oldDiv.marker)
label.delete(oldDiv.marker)
if not na(oldDiv.trendLine)
line.delete(oldDiv.trendLine)
// ─────────────────────────────────────────────────────────────────────────────
// MOMENTUM BURST DETECTION
// ─────────────────────────────────────────────────────────────────────────────
detectMomentumBurst() =>
float burstStrength = 0.0
bool isBurst = false
int burstIncrement = 0
// Calculate momentum acceleration
momAcceleration = ultraMomentum - ultraMomentum[1]
volSpike = volume / nz(volSma20, 1.0)
// Burst conditions
if math.abs(momAcceleration) > burstThreshold and volSpike > 1.5
burstStrength := math.abs(momAcceleration) * volSpike
isBurst := true
burstIncrement := 1
[isBurst, burstStrength, burstIncrement]
[isBurst, burstStrength, burstIncrement] = detectMomentumBurst()
if burstIncrement > 0
burstCount += burstIncrement
if isBurst and showMomentumBursts
if array.size(bursts) > 5
oldBurst = array.shift(bursts)
if not na(oldBurst.burstBox)
box.delete(oldBurst.burstBox)
if not na(oldBurst.burstLabel)
label.delete(oldBurst.burstLabel)
MomentumBurst newBurst = MomentumBurst.new(
bar_index, burstStrength, quantumRSI, volume, na, na
)
array.push(bursts, newBurst)
// ─────────────────────────────────────────────────────────────────────────────
// MOMENTUM VORTEX
// ─────────────────────────────────────────────────────────────────────────────
// Pre-compute ta.* functions at global scope for consistency
float _vortexChange = ta.change(quantumRSI)
float _vortexStdev = ta.stdev(quantumRSI, regimeLookback)
float _vortexFlowChange = ta.change(quantumRSI, flowLength)
if showMomentumVortex
// Update vortex values
if array.size(vortex.values) >= flowLength
array.shift(vortex.values)
array.push(vortex.values, quantumRSI)
// Calculate vortex properties
if array.size(vortex.values) > 1
vortex.rotation := _vortexChange
vortex.intensity := _vortexStdev * quantumSensitivity
// Update flow direction
flowDirection := _vortexFlowChange > 0 ? 1 : -1
// ─────────────────────────────────────────────────────────────────────────────
// QUANTUM MOMENTUM COLOR CALCULATION
// ─────────────────────────────────────────────────────────────────────────────
getQuantumMomentumColor(float rsi, float momentum, float quantum) =>
color.from_gradient(rsi, 0, 100, getAdaptiveColor(), QMA_NEUTRAL_GRAY)
momentumColor = getQuantumMomentumColor(quantumRSI, rsiMomentum, quantumValue)
// Glow effect calculation
getGlowColor(baseColor, intensity) =>
if showGlowEffect
glowWidth = math.max(1, math.round(intensity / 20))
glowAlpha = math.max(30, 100 - intensity)
color.new(baseColor, glowAlpha)
else
na
// ─────────────────────────────────────────────────────────────────────────────
// PLOTTING - QUANTUM RSI LINES
// ─────────────────────────────────────────────────────────────────────────────
// Main quantum RSI with glow effect
mainPlot = plot(quantumRSI, "Quantum RSI", color=momentumColor, linewidth=3)
// Removed glow plots to resolve scope error
// plot(showGlowEffect ? quantumRSI : na, "Glow 1", color=getGlowColor(momentumColor, regime.strength), linewidth=6)
// plot(showGlowEffect ? quantumRSI : na, "Glow 2", color=getGlowColor(momentumColor, regime.strength * 0.7), linewidth=9)
// Multi-layer RSI visualization
p1 = plot(showMultiLayer ? rsiFastSmooth : na, "Fast RSI", color=color.new(QMA_QUANTUM_GREEN, 60), linewidth=2)
p2 = plot(showMultiLayer ? rsiSlowSmooth : na, "Slow RSI", color=color.new(QMA_QUANTUM_ORANGE, 60), linewidth=2)
p3 = plot(showMultiLayer ? rsiUltraSmooth : na, "Ultra-Fast RSI", color=color.new(QMA_QUANTUM_PURPLE, 70), linewidth=1)
// Multi-layer fills
fill(p1, p2, color=showMultiLayer ? color.new(rsiDelta > 0 ? QMA_QUANTUM_GREEN : QMA_QUANTUM_ORANGE, 85) : na)
fill(p2, p3, color=showMultiLayer ? color.new(ultraMomentum > 0 ? QMA_QUANTUM_PURPLE : QMA_QUANTUM_PINK, 90) : na)
// Volume-weighted RSI
vwPlot = plot(useVolumeWeight ? vwRsiSmooth : na, "Volume-Weighted RSI", color=color.new(QMA_WARNING_YELLOW, 50), linewidth=2, style=plot.style_line)
// ─────────────────────────────────────────────────────────────────────────────
// PLOTTING - QUANTUM LEVELS AND ZONES
// ─────────────────────────────────────────────────────────────────────────────
// Dynamic quantum levels
quantumOb = obLevel + quantumValue * 5
quantumOs = osLevel + quantumValue * 5
plot(quantumOb, "Quantum Overbought", color=color.new(QMA_QUANTUM_RED, 50), linewidth=1, style=plot.style_line)
plot(quantumOs, "Quantum Oversold", color=color.new(QMA_QUANTUM_CYAN, 50), linewidth=1, style=plot.style_line)
hline(50, "Centerline", color=color.new(#4a5568, 0), linestyle=hline.style_solid)
hline(60, "Upper Mid", color=color.new(#4a5568, 70), linestyle=hline.style_dotted)
hline(40, "Lower Mid", color=color.new(#4a5568, 70), linestyle=hline.style_dotted)
// Quantum zones with animated fill
obZone = plot(quantumOb, "OB Zone Top", color=na, display=display.none)
obZone2 = plot(100, "OB Zone Bottom", color=na, display=display.none)
fill(obZone, obZone2, color=QMA_OB_ZONE)
osZone = plot(quantumOs, "OS Zone Top", color=na, display=display.none)
osZone2 = plot(0, "OS Zone Bottom", color=na, display=display.none)
fill(osZone, osZone2, color=QMA_OS_ZONE)
// Quantum equilibrium zone
eqZone = plot(45, "Equilibrium Top", color=na, display=display.none)
eqZone2 = plot(55, "Equilibrium Bottom", color=na, display=display.none)
fill(eqZone, eqZone2, color=QMA_QUANTUM_ZONE)
// ─────────────────────────────────────────────────────────────────────────────
// PLOTTING - QUANTUM MOMENTUM HISTOGRAM
// ─────────────────────────────────────────────────────────────────────────────
histValue = showMomentumBars ? rsiDelta + (quantumValue * 2) : na
histAcceleration = showMomentumBars ? ta.change(histValue, 1) : na
histColor = showMomentumBars ? color.from_gradient(histValue, -10, 10, color.from_gradient(histAcceleration, -5, 5, QMA_EXTREME_BEAR, QMA_EXTREME_BULL), color.new(QMA_NEUTRAL_GRAY, 50)) : na
plot(showMomentumBars ? histValue + 50 : na, "Quantum Momentum", color=histColor, style=plot.style_columns, histbase=50, linewidth=histogramWidth)
plot(showMomentumBars ? ultraMomentum * 5 + 50 : na, "Ultra Momentum", color=color.new(QMA_QUANTUM_PURPLE, 70), style=plot.style_columns, histbase=50, linewidth=1)
// ─────────────────────────────────────────────────────────────────────────────
// PLOTTING - QUANTUM REGIME BACKGROUND
// ─────────────────────────────────────────────────────────────────────────────
regimeBgColor = switch regime.current
3 => color.new(QMA_EXTREME_BULL, 92)
2 => color.new(QMA_STRONG_BULL, 94)
1 => color.new(QMA_MILD_BULL, 95)
-1 => color.new(QMA_MILD_BEAR, 95)
-2 => color.new(QMA_STRONG_BEAR, 94)
-3 => color.new(QMA_EXTREME_BEAR, 92)
=> na
// Quantum pulse background
quantumPulseBg = showPulseEffect ? color.new(na(regimeBgColor) ? QMA_NEUTRAL_GRAY : regimeBgColor, 95) : na
bgcolor(showRegimeBG ? regimeBgColor : na)
bgcolor(showPulseEffect ? quantumPulseBg : na)
// ─────────────────────────────────────────────────────────────────────────────
// PLOTTING - QUANTUM DIVERGENCE MARKERS
// ─────────────────────────────────────────────────────────────────────────────
bullDiv = false
bearDiv = false
hiddenBullDiv = false
hiddenBearDiv = false
if array.size(divergences) > 0
DivergencePoint lastDiv = array.get(divergences, array.size(divergences) - 1)
if lastDiv.barIdx == bar_index - pivotLookback
if lastDiv.isBullish and not lastDiv.isHidden
bullDiv := true
else if not lastDiv.isBullish and not lastDiv.isHidden
bearDiv := true
else if lastDiv.isBullish and lastDiv.isHidden
hiddenBullDiv := true
else if not lastDiv.isBullish and lastDiv.isHidden
hiddenBearDiv := true
// Enhanced divergence shapes with strength-based sizing
// plotshape size must be const string, so we use separate calls per size
bullDivStrong = bullDiv and array.size(divergences) > 0 ? array.get(divergences, array.size(divergences) - 1).strength > 1.0 : false
bearDivStrong = bearDiv and array.size(divergences) > 0 ? array.get(divergences, array.size(divergences) - 1).strength > 1.0 : false
// Bull divergence signals with text labels
plotshape(bullDiv and bullDivStrong, "Bull Div Strong", shape.labelup, location.bottom, QMA_DIVERGENCE_BULL, text="BULL DIV", textcolor=color.white, size=size.small, offset=-pivotLookback)
plotshape(bullDiv and not bullDivStrong, "Bull Div Weak", shape.triangleup, location.bottom, color.new(QMA_DIVERGENCE_BULL, 30), text="div", textcolor=color.white, size=size.tiny, offset=-pivotLookback)
// Bear divergence signals with text labels
plotshape(bearDiv and bearDivStrong, "Bear Div Strong", shape.labeldown, location.top, QMA_DIVERGENCE_BEAR, text="BEAR DIV", textcolor=color.white, size=size.small, offset=-pivotLookback)
plotshape(bearDiv and not bearDivStrong, "Bear Div Weak", shape.triangledown, location.top, color.new(QMA_DIVERGENCE_BEAR, 30), text="div", textcolor=color.white, size=size.tiny, offset=-pivotLookback)
// Hidden divergence signals with gradient-colored text labels
plotshape(hiddenBullDiv, "Hidden Bullish Div", shape.labelup, location.bottom, color.new(QMA_HIDDEN_DIV, 20), text="H-BULL", textcolor=color.white, size=size.tiny, offset=-pivotLookback)
plotshape(hiddenBearDiv, "Hidden Bearish Div", shape.labeldown, location.top, color.new(QMA_HIDDEN_DIV, 20), text="H-BEAR", textcolor=color.white, size=size.tiny, offset=-pivotLookback)
// ─────────────────────────────────────────────────────────────────────────────
// QUANTUM ZONES VISUALIZATION
// ─────────────────────────────────────────────────────────────────────────────
if barstate.islast and showQuantumZones
int zoneLookback = math.min(regime.duration, 500)
for zone in quantumZones
if zone.isActive
zone.zoneBox := box.new(
bar_index - zoneLookback, zone.lower,
bar_index, zone.upper,
bgcolor=color.new(zone.upper > 50 ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED, 85),
border_color=color.new(zone.upper > 50 ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED, 30),
text=""
)
zone.midLine := line.new(
bar_index - zoneLookback, (zone.upper + zone.lower) / 2,
bar_index, (zone.upper + zone.lower) / 2,
color=color.new(QMA_NEUTRAL_GRAY, 50),
style=line.style_dashed
)
// ─────────────────────────────────────────────────────────────────────────────
// MOMENTUM BURST VISUALIZATION (signal-only, no boxes)
// ─────────────────────────────────────────────────────────────────────────────
// ─────────────────────────────────────────────────────────────────────────────
// MOMENTUM VORTEX VISUALIZATION
// ─────────────────────────────────────────────────────────────────────────────
if showMomentumVortex and barstate.islast
// Clear old particles
for particle in vortex.particles
label.delete(particle)
array.clear(vortex.particles)
// Create vortex particles
if vortex.intensity > 0.5
for i = 0 to math.min(10, math.round(vortex.intensity * 5))
angle = (i / 10) * 2 * math.pi + vortex.rotation
radius = math.min(vortex.intensity * 10, 5)
int particleX = math.max(0, math.min(bar_index, int(math.round(bar_index + math.cos(angle) * radius))))
particleY = quantumRSI + math.sin(angle) * radius
particle = label.new(
particleX, particleY, "●",
color=color.new(QMA_QUANTUM_CYAN, 70 - i * 5),
size=size.tiny
)
array.push(vortex.particles, particle)
// ─────────────────────────────────────────────────────────────────────────────
// QUANTUM DASHBOARD
// ─────────────────────────────────────────────────────────────────────────────
if showDashboard
var table dashboard = table.new(position.top_right, 3, 12,
bgcolor=color.new(QMA_DARK_MATTER, 0),
border_color=color.new(QMA_NEUTRAL_GRAY, 30),
border_width=1,
frame_color=color.new(QMA_QUANTUM_CYAN, 40),
frame_width=2)
if barstate.islast
regimeText = switch regime.current
3 => "EXTREME BULL"
2 => "▲ STRONG BULL"
1 => "△ MILD BULL"
-1 => "▽ MILD BEAR"
-2 => "▼ STRONG BEAR"
-3 => "EXTREME BEAR"
=> "◆ NEUTRAL"
regimeCol = switch regime.current
3 => QMA_EXTREME_BULL
2 => QMA_STRONG_BULL
1 => QMA_MILD_BULL
-1 => QMA_MILD_BEAR
-2 => QMA_STRONG_BEAR
-3 => QMA_EXTREME_BEAR
=> QMA_NEUTRAL_GRAY
momentumText = rsiMomentum > 2 ? "⬆ STRONG UP" : rsiMomentum > 0 ? "↑ UP" : rsiMomentum < -2 ? "⬇ STRONG DOWN" : rsiMomentum < 0 ? "↓ DOWN" : "— FLAT"
momentumCol = rsiMomentum > 0 ? QMA_QUANTUM_GREEN : rsiMomentum < 0 ? QMA_QUANTUM_RED : QMA_NEUTRAL_GRAY
quantumText = quantumValue > 0.3 ? "HIGH" : quantumValue > 0 ? "MEDIUM" : quantumValue < -0.3 ? "LOW" : "NEUTRAL"
quantumCol = quantumValue > 0 ? QMA_QUANTUM_CYAN : quantumValue < 0 ? QMA_QUANTUM_PURPLE : QMA_NEUTRAL_GRAY
// Strength bar visual
int strengthBars = math.round(regime.strength / 10)
string strengthBar = ""
for i = 0 to 9
strengthBar += i < strengthBars ? "█" : "░"
// RSI zone text
rsiZone = quantumRSI > obLevel ? "OVERBOUGHT" : quantumRSI < osLevel ? "OVERSOLD" : quantumRSI > 55 ? "BULLISH" : quantumRSI < 45 ? "BEARISH" : "NEUTRAL"
rsiZoneCol = quantumRSI > obLevel ? QMA_QUANTUM_RED : quantumRSI < osLevel ? QMA_QUANTUM_CYAN : quantumRSI > 55 ? QMA_QUANTUM_GREEN : quantumRSI < 45 ? QMA_QUANTUM_RED : QMA_NEUTRAL_GRAY
// Title row
table.cell(dashboard, 0, 0, " QUANTUM MOMENTUM ANALYZER ", text_color=QMA_QUANTUM_CYAN, text_size=size.normal, bgcolor=color.new(QMA_DARK_MATTER, 0))
table.cell(dashboard, 1, 0, "", bgcolor=color.new(QMA_DARK_MATTER, 0))
table.cell(dashboard, 2, 0, "", bgcolor=color.new(QMA_DARK_MATTER, 0))
table.merge_cells(dashboard, 0, 0, 2, 0)
// QRSI value - big display
table.cell(dashboard, 0, 1, " QRSI ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 1, str.tostring(quantumRSI, "#.##"), text_color=momentumColor, text_size=size.normal, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 1, rsiZone, text_color=rsiZoneCol, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// Regime
table.cell(dashboard, 0, 2, " Regime ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 1, 2, regimeText, text_color=regimeCol, text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 2, 2, str.tostring(regime.duration) + " bars", text_color=color.new(#808080, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
// Strength with bar
table.cell(dashboard, 0, 3, " Strength ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 3, str.tostring(regime.strength, "#.#") + "%", text_color=regimeCol, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 3, strengthBar, text_color=regimeCol, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// Momentum
table.cell(dashboard, 0, 4, " Momentum ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 1, 4, momentumText, text_color=momentumCol, text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 2, 4, str.tostring(rsiMomentum, "#.##"), text_color=momentumCol, text_size=size.small, bgcolor=color.new(#12121f, 0))
// Quantum State
table.cell(dashboard, 0, 5, " Quantum ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 5, quantumText, text_color=quantumCol, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 5, str.tostring(quantumValue, "#.###"), text_color=quantumCol, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// Delta
deltaCol = rsiDelta > 0 ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED
deltaArrow = rsiDelta > 0 ? "▲ " : rsiDelta < 0 ? "▼ " : " "
table.cell(dashboard, 0, 6, " Delta ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 1, 6, deltaArrow + str.tostring(rsiDelta, "#.##"), text_color=deltaCol, text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 2, 6, rsiDelta > 1 ? "EXPANDING" : rsiDelta < -1 ? "CONTRACTING" : "STABLE", text_color=deltaCol, text_size=size.small, bgcolor=color.new(#12121f, 0))
// Fast/Slow RSI
table.cell(dashboard, 0, 7, " Fast RSI ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 7, str.tostring(rsiFastSmooth, "#.#"), text_color=color.new(QMA_QUANTUM_GREEN, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 7, rsiFastSmooth > rsiSlowSmooth ? "ABOVE SLOW" : "BELOW SLOW", text_color=rsiFastSmooth > rsiSlowSmooth ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// Slow RSI
table.cell(dashboard, 0, 8, " Slow RSI ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 1, 8, str.tostring(rsiSlowSmooth, "#.#"), text_color=color.new(QMA_QUANTUM_ORANGE, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 2, 8, rsiSlowSmooth > 50 ? "BULLISH BIAS" : "BEARISH BIAS", text_color=rsiSlowSmooth > 50 ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED, text_size=size.small, bgcolor=color.new(#12121f, 0))
// VW RSI
table.cell(dashboard, 0, 9, " VW-RSI ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 9, str.tostring(vwRsiSmooth, "#.#"), text_color=QMA_WARNING_YELLOW, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 9, vwRsiSmooth > quantumRSI ? "PREMIUM" : "DISCOUNT", text_color=vwRsiSmooth > quantumRSI ? QMA_QUANTUM_GREEN : QMA_QUANTUM_RED, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// Bursts
table.cell(dashboard, 0, 10, " Bursts ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 1, 10, str.tostring(burstCount), text_color=QMA_MOMENTUM_BURST, text_size=size.small, bgcolor=color.new(#12121f, 0))
table.cell(dashboard, 2, 10, burstCount > 5 ? "HIGH ACTIVITY" : burstCount > 0 ? "ACTIVE" : "QUIET", text_color=burstCount > 5 ? QMA_MOMENTUM_BURST : burstCount > 0 ? QMA_WARNING_YELLOW : QMA_NEUTRAL_GRAY, text_size=size.small, bgcolor=color.new(#12121f, 0))
// Vortex
table.cell(dashboard, 0, 11, " Vortex ", text_color=color.new(#b0b0b0, 0), text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 1, 11, str.tostring(vortex.intensity, "#.##"), text_color=vortex.intensity > 1 ? QMA_QUANTUM_CYAN : QMA_NEUTRAL_GRAY, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
table.cell(dashboard, 2, 11, flowDirection > 0 ? "↑ BULLISH FLOW" : flowDirection < 0 ? "↓ BEARISH FLOW" : "— NEUTRAL", text_color=flowDirection > 0 ? QMA_QUANTUM_GREEN : flowDirection < 0 ? QMA_QUANTUM_RED : QMA_NEUTRAL_GRAY, text_size=size.small, bgcolor=color.new(#1a1a2e, 0))
// ─────────────────────────────────────────────────────────────────────────────
// QUANTUM ALERTS
// ─────────────────────────────────────────────────────────────────────────────
alertcondition(ta.crossover(quantumRSI, quantumOb), "Quantum Overbought Entry", "Quantum RSI entered overbought zone")
alertcondition(ta.crossunder(quantumRSI, quantumOs), "Quantum Oversold Entry", "Quantum RSI entered oversold zone")
alertcondition(bullDiv, "Bullish Divergence", "Bullish quantum divergence detected")
alertcondition(bearDiv, "Bearish Divergence", "Bearish quantum divergence detected")
alertcondition(regimeSeries != regimeSeries[1] and regimeSeries > 0, "Bullish Regime Change", "Momentum shifted to bullish quantum regime")
alertcondition(regimeSeries != regimeSeries[1] and regimeSeries < 0, "Bearish Regime Change", "Momentum shifted to bearish quantum regime")
alertcondition(isBurst, "Momentum Burst", "Quantum momentum burst detected")
alertcondition(vortex.intensity > 1, "Vortex Activation", "Momentum vortex intensity threshold reached")
alertcondition(quantumValue > 0.5, "Quantum High State", "Quantum amplitude entered high state")
alertcondition(quantumValue < -0.5, "Quantum Low State", "Quantum amplitude entered low state")
// ─────────────────────────────────────────────────────────────────────────────
// MOMENTUM FLOW VISUALIZATION
// ─────────────────────────────────────────────────────────────────────────────
if showMomentumFlow and barstate.islast
// Draw momentum flow lines
for i = 1 to flowLength
if bar_index - i >= 0
flowAlpha = (flowLength - i) / flowLength * 100
flowColor = flowDirection > 0 ? color.new(QMA_QUANTUM_GREEN, 100 - flowAlpha) : color.new(QMA_QUANTUM_RED, 100 - flowAlpha)
flowY = quantumRSI[i]
line.new(
bar_index - i, flowY,
bar_index - i + 1, quantumRSI[i - 1],
color=flowColor,
width=math.max(1, flowLength - i),
style=line.style_solid
)
// ─────────────────────────────────────────────────────────────────────────────
// CLEANUP FUNCTIONS
// ─────────────────────────────────────────────────────────────────────────────
// Cleanup quantum zones
if barstate.isconfirmed and array.size(quantumZones) > 5
for i = array.size(quantumZones) - 1 to 0
zone = array.get(quantumZones, i)
if not na(zone.zoneBox)
box.delete(zone.zoneBox)
if not na(zone.midLine)
line.delete(zone.midLine)
array.remove(quantumZones, i)
break
// Cleanup momentum bursts
if barstate.isconfirmed and array.size(bursts) > 5
for i = array.size(bursts) - 1 to 0
burst = array.get(bursts, i)
if not na(burst.burstBox)
box.delete(burst.burstBox)
if not na(burst.burstLabel)
label.delete(burst.burstLabel)
array.remove(bursts, i)
break
// Cleanup vortex particles
if barstate.isconfirmed and array.size(vortex.particles) > 20
for i = array.size(vortex.particles) - 1 to 0
if i >= 20
particle = array.get(vortex.particles, i)
label.delete(particle)
array.remove(vortex.particles, i)
Disclaimer
QuantForge publishes technical material about indicators: what they do, how they are built, and how you can experiment with them in code and on charts. All of this is offered for education and illustration only. It is not financial, investment, or trading advice, and it should not be read as a recommendation to buy, sell, or hold any asset. Past or simulated performance does not guarantee future results. You are responsible for your own decisions; seek independent professional advice where appropriate.

![Quantum Momentum Analyzer [JOAT] – Multi-Layer RSI with Regime Detection](https://quantforge.org/wp-content/uploads/2026/03/screenshot-7.webp)