OPEN-SOURCE SCRIPT
Cập nhật

RegimeFlow V2

834
REGIMEFLOW V2 — Donchian Regime Detection + Synthetic Fear & Greed + Market Regime Classification

RegimeFlow V2 is a visual-first overlay indicator that tells you the current market regime at a glance. Every plot element on your chart — the colored channel fill, the touch triangles, the divergence labels, the transition dots, the Fisher scoring bar, and the volume spike diamonds — works together to paint a real-time picture of whether the market is accumulating, distributing, exhausting, breaking out, transitioning, or ranging. The dense info table synthesizes all of this into a single Regime label so you never have to guess.

WHAT YOU SEE ON THE CHART

The Donchian channel bands (orange upper, blue lower, gray midline) define the structural boundaries. Price interacts with these bands constantly, and RegimeFlow tracks every interaction to build a rolling directional pressure profile.

The channel fill shading between the upper and lower bands changes color based on the synthetic Fear and Greed score. When the channel glows red, the market is in extreme fear. Pink shading indicates moderate fear. No fill means neutral conditions. Green fill means greed, and cyan fill means extreme greed. This gives you an instant, unmistakable visual read of the current sentiment regime without looking at any numbers. On a weekly Bitcoin chart, you can scroll back years and immediately see every bull and bear phase painted in color between the bands.

Orange down-triangles appear above bars that touch or come within the configurable margin of the upper Donchian band. Blue up-triangles appear below bars that touch the lower band. Yellow diamonds mark wide-range bars that span the full channel, touching both bands simultaneously. These markers are the raw data that drives the entire touch counting system. Clusters of blue triangles at the bottom of a move indicate sustained selling pressure and accumulation. Clusters of orange triangles at the top indicate distribution. Isolated touches are noise. Streaks are signal.

Yellow circle dots mark Fear and Greed zone transitions. A yellow dot below a bar appears when the F&G score exits the fear zone and enters neutral, suggesting selling pressure is easing. A yellow dot above a bar appears when the score exits the greed zone and enters neutral, suggesting buying enthusiasm is cooling. These transition points historically cluster near regime inflection points and are among the most actionable signals the indicator produces.

Green "D" labels below bars mark bullish ADX divergences, where price made a lower low but ADX also made a lower low, revealing that the downtrend is losing conviction. Red "D" labels above bars mark bearish ADX divergences, where price made a higher high but ADX failed to confirm, revealing that the uptrend is fading. These labels are offset to align precisely with the pivot bar where the divergence formed. An optional ADX minimum filter (default off) can suppress divergences when trend strength is below 18, though this is intentionally disabled by default because exhaustion signals at trend death are often the most valuable.

Green diamond markers appear above bars with bullish volume spikes — bars where volume exceeded the configurable multiplier (default 2.5x) of its 20-period SMA on an up-close candle. Red diamond markers appear below bars with bearish volume spikes on down-close candles. Volume spikes tend to cluster at regime turning points, adding confirmation weight to touch events and divergence signals happening on the same bars.

The Fisher Transform scoring bar plots as a color-coded circle at the bottom of the chart on every bar, creating a continuous visual ribbon. Dark green circles indicate deeply oversold Fisher readings (below -2.0), lime green circles show moderate oversold (-1.0 to -2.0), white circles show neutral territory (-1.0 to +1.0), pink circles show moderate overbought (+1.0 to +2.0), and maroon circles indicate extreme overbought conditions (above +2.0). Reading the color sequence of this ribbon reveals the cycle rhythm: a run of dark green circles transitioning to lime, then white, then pink tells you the cycle is turning from oversold to overbought. All thresholds and colors are fully adjustable.

THE INFO TABLE

The table packs 13 rows of data into a compact overlay in any corner of your chart.

The touch counting section (rows 1-5) shows upper touches, lower touches, net score, upper touch percentage, and directional bias across three rolling windows: 270, 180, and 90 bars. Reading across from left (longest lookback) to right (shortest) reveals regime transitions in real time. When the 270-bar column reads BULLISH but the 90-bar column has flipped BEARISH, a regime change is developing from the most recent price action outward.

The ADX row shows trend strength with four-tier color coding: white background when ADX is below 18 (no trend), gray for 18-24 (low trend), pink for 25-34 (moderate trend), and maroon for 35+ (strong trend). The +DI and -DI values show which side is dominating, with green background when +DI leads and red when -DI leads.

The RSI row shows the 14-period RSI with contextual labels (OVERSOLD, WEAK, NEUTRAL, STRONG, OVERBOUGHT) and color coding matching the thresholds. The touch streak counter shares this row, displaying the current consecutive touch count with directional arrows (e.g., ▼4 means four consecutive lower band touches).

The HTF row pulls the higher timeframe Donchian channel position via a single consolidated request.security() call. It shows where the current price sits within the higher timeframe channel as a percentage and a BULLISH, BEARISH, or NEUTRAL label. The default higher timeframe is Daily, switchable to 1H, 4H, or Weekly.

The Volume row shows the current volume as a ratio of its 20-period SMA (e.g., "3.2x") and whether a spike is active.

The Fisher row displays the current Fisher Transform value and its zone label (XTRM OS, OVERSOLD, NEUTRAL, OVERBOUGHT, XTRM OB) with matching background color.

The F&G row shows the smoothed synthetic Fear and Greed composite score (0-100) with its zone label. The score blends five calibrated components: RSI, volatility (ATR ratio with corrected linear scaling), directional volume pressure, price deviation from its moving average, and Donchian channel position, each with adjustable weights.

The Regime row at the bottom is the synthesis — a single word that tells you what the market is doing right now. The classification logic uses confluence of the 180-bar net score, Fear and Greed zone, Fisher Transform reading, and ADX trend strength to produce one of six labels. ACCUMULATE (dark green) appears when net pressure is bearish, sentiment is in fear, and Fisher is oversold — smart money is buying the dip. DISTRIBUTE (maroon) appears when net pressure is bullish, sentiment is in greed, and Fisher is overbought — smart money is selling into strength. EXHAUSTION (orange) appears when ADX shows no trend but Fisher is at an extreme — the current move is dying. BREAKOUT with an up or down arrow (green or red) appears when ADX is strong, net pressure confirms direction, and Fisher agrees — the trend is accelerating. TRANSITION (gold) appears when signals are mixed — the regime is shifting and clarity has not yet emerged. RANGE (gray) appears when there is no directional conviction across any component.

SYNTHETIC FEAR AND GREED ENGINE

The F&G score is built from five independently calibrated components. RSI (default weight 25) maps the 14-period RSI directly to the 0-100 scale. Volatility (weight 20) compares current ATR to its 50-period baseline using a corrected linear formula that properly centers at 50 when ATR is normal, reaches 100 when ATR is compressed to half its average, and reaches 0 when ATR is 1.5x its average. Volume Pressure (weight 15) measures directional volume — high volume on up bars pushes the score toward greed, high volume on down bars pushes toward fear, and low volume stays neutral. Price vs Moving Average (weight 20) tracks percentage deviation from a configurable SMA. Channel Position (weight 20) maps where price sits within the Donchian channel. Optional EMA smoothing (default 5 periods) reduces bar-to-bar noise and prevents false zone transition signals.

SETTINGS OVERVIEW

The indicator is organized into eight settings groups. Donchian Channel controls the period and band visibility. Counter controls the touch margin. Display controls the table and touch markers. Fear and Greed controls the five component weights and smoothing. F&G Levels and Colors controls all five zone thresholds, all five zone colors, and the transition dot toggle. ADX Divergence controls pivot detection parameters and the optional ADX minimum filter. Enhancements controls volume spike markers, HTF bias, and streak display. Fisher Transform controls the scoring bar with its own length, thresholds, and colors.

ALERTS

RegimeFlow V2 provides twelve alert conditions: upper and lower band touches, strong bullish and bearish net scores, bullish and bearish ADX divergences, volume spikes, upper and lower touch streaks of 5+ bars, Fisher extreme oversold and overbought crosses, and Fear and Greed zone transitions (fear to neutral, greed to neutral).

HOW TO USE IT

RegimeFlow V2 is designed so you can read the market regime without looking at the table at all. The colored channel fill tells you the sentiment. The touch triangles tell you the pressure. The transition dots tell you when regimes shift. The Fisher bar ribbon tells you the cycle position. The divergence labels tell you when conviction is fading. The volume diamonds tell you when participation surges. The table is there for precision when you need numbers, but the chart tells the story visually.

Use it on weekly timeframes for macro regime identification, daily for swing context, and 1H or 4H for tactical reads. The Regime label at the bottom of the table gives you the synthesized answer: are you accumulating, distributing, exhausting, breaking out, transitioning, or ranging? That single word, backed by the confluence of every component, is the output that drives your decision framework.
Phát hành các Ghi chú
cosmetic
Phát hành các Ghi chú
cosmetic
Phát hành các Ghi chú
cosmetic
Phát hành các Ghi chú
RegimeFlow V2 is a Donchian channel regime detection system with a synthetic Fear and Greed index, four-type divergence engine, Fisher Transform, and an eight-state market regime classifier. It answers "what is the market doing right now?" across multiple analytical dimensions and synthesizes the answer into a single regime label.

The foundation is Donchian channel touch counting. Upper band touches represent distribution pressure (sellers testing highs), lower band touches represent accumulation pressure (buyers testing lows). Touches are counted over three rolling windows (90, 180, and 270 bars) and the net score reveals directional bias at three time scales simultaneously. A configurable touch margin determines how close price needs to get to the band to count — either a fixed percentage or an ATR-adaptive mode that auto-calibrates based on the asset's current volatility. ATR mode uses ATR(14) multiplied by a configurable factor, so the same settings work across assets with vastly different volatility profiles without manual adjustment.

The synthetic Fear and Greed index blends five components: RSI (momentum sentiment), ATR compression ratio (volatility regime), directional volume pressure (volume weighted by price direction), price vs 50-period SMA (trend displacement), and Donchian channel position (where price sits within the structural range). Each component is normalized to a 0-100 scale before weighting, and the blend is optionally EMA-smoothed. Zone transition dots fire when the score exits fear or greed back to neutral — these transitions often mark the inflection where the crowd has finished panicking or celebrating.

Four types of pivot-based divergence detection run simultaneously, each measuring a different dimension of exhaustion. RSI divergence detects momentum exhaustion — price makes a new extreme but RSI fails to confirm. ADX divergence detects trend conviction fading — price pushes further but trend strength weakens. ROC divergence detects velocity deceleration — the rate of price change is slowing despite new extremes. Reversion Index divergence detects efficiency shifts using a signed Kaufman Efficiency Ratio — the market's directional efficiency is changing at the new extreme. All four share configurable pivot settings (5 left, 4 right, max 24 bar lookback) and each can be independently toggled. RSI divergence plots as larger cyan/magenta diamonds near price, ADX as smaller cyan/magenta diamonds, ROC as deep purple squares, and RI as white crosses.

The Fisher Transform provides an additional overbought/oversold oscillator independent from RSI. Its value and zone label appear in the info table when enabled. The Fisher calculation uses a 10-bar lookback with smoothed recursive normalization and clamping for numerical stability.

Higher timeframe bias pulls the Donchian channel position from a configurable HTF (default Daily) to show where the macro trend sits relative to its own structural range. Volume spike detection flags bars where volume exceeds a configurable multiple (default 2.5x) of its 20-bar SMA, with green diamonds for bullish spikes and red for bearish. Touch streak counting tracks consecutive bars touching the same band — sustained streaks of 5 or more often precede breakouts or breakdowns.

The eight-state regime classifier synthesizes all components into a single market label. EXHAUSTION fires when ADX is dead but Fisher has reached an extreme — trend has died at a price extreme, often marking major turning points. ACCUMULATE fires when net touch bias is bearish, Fear and Greed is in the fear zone, and Fisher is oversold — all three dimensions agree that sellers are exhausted and smart money is absorbing supply. DISTRIBUTE is the mirror — bullish bias, greed zone, Fisher overbought. BREAKOUT fires when ADX is strong, net bias confirms direction, and Fisher agrees — the initial breakout with full momentum confirmation. TRENDING fires when ADX is strong and DI spread exceeds 5 points confirming direction with net bias aligned, but without requiring Fisher agreement — the steady established trend state distinct from the initial breakout pop. COMPRESSION fires when ADX is dead, Fisher is tight (near zero, not extreme), and net bias is flat — the coiling state where energy is building but direction is unknown, often preceding a significant move. TRANSITION fires when signals are mixed — some bullish, some bearish, no clean confluence. RANGE is the default when no pattern matches — directionless, low conviction.

The info table uses a dark theme with cyan labels on dark backgrounds, alternating row colors, and colored text for values. Three-column layout shows the 270, 180, and 90 bar windows side by side for upper touches, lower touches, net score, upper percentage, and directional bias. Additional rows display ADX with DI spread, RSI with zone label, touch streak, HTF bias with channel position percentage, volume ratio with spike status, Fisher Transform with zone label, Fear and Greed score with zone label, and the final regime classification. The table supports nine-position placement.

Twenty alert conditions cover band touches, strong bullish/bearish net scores, all four divergence types (bullish and bearish for each), volume spikes, upper and lower streaks of 5 or more, Fisher extreme crossings, Fear and Greed zone transitions, and regime changes. All alert messages include ticker and timeframe context.
Phát hành các Ghi chú
cosmetic
Phát hành các Ghi chú
cosmetic

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.