OPEN-SOURCE SCRIPT
تم تحديثه

Volatility Regime Cycle [AGPro Series]

729
Volatility Regime Cycle [AGPro Series]

🌀 Overview

Volatility Regime Cycle classifies every bar on your chart into one of four distinct volatility phases: Contraction, Expansion, Climax, and Reset. Unlike traditional trend or regime indicators that focus on price direction, this tool maps the cyclical behavior of volatility itself — helping traders recognize whether the market is coiling, releasing, climaxing, or resetting. Each phase is detected through a multi-factor confluence engine and displayed with gradient background shading, transition markers, and S/R-style climax reaction zones. The framework is asset- and timeframe-agnostic: it adapts to crypto, forex, indices, stocks, and commodities on any timeframe.


💎 Unique Edge

Most volatility tools present a single metric (ATR, Bollinger Width, VIX proxy). Volatility Regime Cycle differs in structure and intent:

🔸 Phase-based classification, not just a reading — every bar is assigned to a named regime with a trader-actionable bias.
🔸 Multi-factor confluence scoring — five independent volatility inputs (ATR level, BB Width level, BB/KC squeeze, volume z-score, ATR rate-of-change) vote on the active phase. No single factor can dominate.
🔸 Winsorized normalization — outlier events (single extreme bars) do not compress the scale and hide current readings, a common flaw in simple percentile-based tools.
🔸 Climax Reaction Zones — each Climax event is preserved as an S/R-style rectangle with mid-pivot line, creating a memory of past volatility exhaustion levels that often act as future reaction areas.
🔸 Cycle-aware analytics — tracks historical phase durations and estimates current cycle progress based on rolling averages of past phases of the same type.
🔸 Phase-specific Trader Bias — panel translates the current regime into a plain-language bias (Breakout-watch, Momentum-favor, Reversal-risk, Cooldown).

This is not a Wyckoff phase tool, an Elliott counter, or a Dow-theory classifier. It is a pure volatility-cycle mapper, engineered from the ground up to stand apart from both classical cycle indicators and single-metric volatility meters.


🧠 Methodology

The engine runs three layers:

🔹 Factor Layer
• ATR Level — 14-period ATR, winsorized min-max normalized (5%-95% range) over a configurable lookback window.
• BB Width Level — Bollinger Band width as percent of basis, normalized identically.
• Squeeze State — true when Bollinger Bands are contained inside Keltner Channels (classic volatility compression).
• Volume Z-Score — standardized volume relative to its rolling mean and standard deviation.
• ATR Rate-of-Change — momentum of volatility itself.

🔹 Scoring Layer
Each of the four phases has its own scoring formula that weights the five factors differently. For each bar, all four phase scores are calculated in parallel, and the phase with the highest score is the candidate regime for that bar.

🔹 Confirmation Layer
To suppress whipsaw, the candidate phase must persist for a configurable number of bars (default 3) before replacing the active phase. A minimum phase duration lock additionally prevents rapid flips. Climax events include a de-duplication cooldown so that clustered climax bars produce a single marker rather than a cluster of overlapping labels.

Phase transitions are classified as major (Contraction→Expansion breakouts and Climax entries) or minor (all other routine changes). Only major transitions receive labels; minor changes are shown as subtle dotted lines to keep the chart clean.


🔔 Signals & Alerts

The script exposes alerts for every phase transition as well as two high-value composite events:

🔸 Any Phase Transition — fires whenever the active phase changes.
🔸 Entered Contraction / Expansion / Climax / Reset — fires for specific phase entries.
🔸 Contraction → Expansion (Breakout) — coil release event; of interest to breakout traders.
🔸 Climax Entry (Exhaustion Warning) — volatility peak event; of interest to mean-reversion and risk-management traders.

All alerts fire only on confirmed bar close to prevent intra-bar flip-flop.


⚙️ Key Inputs

🔹 Engine Settings — normalization lookback, ATR length, Bollinger/Keltner length and multipliers, volume z-score length, ATR rate-of-change length, confirmation bars, minimum phase duration.
🔹 Phase Thresholds — low volatility level, high volatility level, climax volatility gate, climax volume z-score threshold, climax de-dup cooldown.
🔹 Visuals — toggles for background shading, major transition labels, minor transition lines, volatility ribbon, current phase label.
🔹 S/R Zones — climax zones toggle, breakout zones toggle, maximum active zones, zone initial length, zone range lookback.
🔹 Panel — show/hide, location, Dark/Light theme, font size.
🔹 Label Sizing — font size for on-chart labels.
🔹 Alerts — per-event toggles.


📘 How to Use

🔸 Breakout traders: watch for Contraction phase on the panel with Trader Bias showing Breakout-watch. When the phase transitions to Expansion, a coil release is underway and a Breakout label is printed. Optional Breakout Zones can be enabled to preserve the breakout level as a retest reference.

🔸 Momentum / trend traders: ride the Expansion phase while Trader Bias reads Momentum-favor. Phase Duration and Cycle Progress on the panel give a sense of where the current momentum leg sits relative to historical averages.

🔸 Mean-reversion / exhaustion traders: a Climax label with Trader Bias Reversal-risk highlights volatility exhaustion. The Climax Reaction Zone drawn at each climax often behaves as a future reaction level and can be used as confluence with other reversal tools.

🔸 Risk managers: the Reset phase with Trader Bias Cooldown typically signals reduced market conviction and can be used to scale down position size until a new Contraction builds up.

🔸 Multi-timeframe reading: run the script on the higher timeframe for regime context and on the lower timeframe for entry timing.

Hover the panel header to see a statistics tooltip with average durations of each phase over the last completed cycles.


⚠️ Limitations & Transparency

🔹 The script does not predict future prices or issue buy/sell recommendations. It is a classification and context tool.
🔹 Phase detection is inherently lagging because it requires the confirmation window and minimum duration lock. This is a deliberate design choice to suppress whipsaw at the cost of some responsiveness.
🔹 Normalization uses a rolling lookback window; the first lookback bars after loading the script may show compressed or unstable readings while the window fills.
🔹 Cycle Progress is an estimate based on historical phase averages and may exceed 100% when the current phase runs longer than past cycles.
🔹 Climax and Reset scores rely partly on volume; on instruments with unreliable or missing volume feeds, volume-dependent factors will contribute less.
🔹 All visual elements are cosmetic and toggleable; they do not alter the underlying phase logic.


🛡️ Risk Disclosure

This indicator is a technical analysis tool. It is not a trading system, not a signal service, not financial advice, and not a guarantee of future results. Trading involves substantial risk of loss. Past market behavior does not predict future market behavior. Users are solely responsible for their own trading decisions, risk management, and position sizing. Always test any tool on your preferred instruments and timeframes with appropriate historical review before using it as part of a live decision-making process.
ملاحظات الأخبار
🔧 UPDATE NOTES - V1.4

This update focuses on readability, chart structure, label balance, and publication-quality visual clarity.

The core purpose of the script remains unchanged.
This release improves how the existing volatility regime logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

• Rebuilt the visual presentation around a cleaner four-phase volatility cycle.
The script still classifies market behavior into Contraction, Expansion, Climax, and Reset, but the chart output is now easier to scan.

• Added a controlled label-density system.
Major labels are now filtered by mode so the chart does not become crowded, while still keeping enough visible high-value events for a premium published screenshot.

• Added state markers and a subtle volatility ribbon.
These elements keep the chart from looking empty on slower timeframes or quieter market windows without flooding the chart with large labels.

• Refined reaction zone handling.
Climax and qualified breakout zones now include centered zone labels so the zone identity is readable directly inside the visual structure.

• Tightened the default publication view after visual QA.
Default label density is now Minimal, phase markers are disabled by default, low-confidence expansion zones are filtered out, and the maximum active zone count is reduced.

• Updated naming and panel standards.
The public script title no longer starts with AG Pro, while the panel title keeps the AG Pro branding. The panel header remains a single merged blue row.


------------------------
Visual Improvements
------------------------

• Improved chart readability by adjusting labels, ribbon behavior, zone spacing, and right-edge phase context.

• Reduced visual clutter to enhance first-glance interpretation.

• Refined visual hierarchy so phase transitions, active regime context, and reaction zones stand out more clearly.

• Adjusted positioning of elements to avoid overlap with candles and reduce label crowding.

• Added centered labels inside reaction zones when zones are displayed.

• Reduced default label density so the chart keeps a cleaner premium look on 4H and higher-timeframe screenshots.


------------------------
Interface & Usability
------------------------

• Optimized panel layout for clearer information flow.

• Improved label readability for better chart interaction.

• Adjusted default visual settings for a more balanced appearance.

• Added configurable label font size and panel font size with Normal as the default.

• Added panel location and theme controls while keeping the panel visible by default.

• Added a cleaner default setup: Minimal label density, larger label gap, fewer active zones, and hidden phase markers unless the user enables them.

• Enhanced overall user experience without changing core volatility-cycle intent.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical purpose of the script.

The goal is to improve clarity, usability, and publication quality, not to introduce predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure and cleaner event filtering.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may affect how signals appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
ملاحظات الأخبار
UPDATE NOTES - V1.5

This update focuses on readability, volatility-state clarity, panel flow, and publication-ready visual structure.

The core purpose of the script remains unchanged.
This release improves how the existing volatility-regime logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.


------------------------
What Changed
------------------------

* Rebuilt the panel flow.
The panel now starts with workflow context, then shows volatility state, cycle phase, progress, ATR / BBW context, and review status.

* Added clearer volatility-state language.
The script now separates Setup, Active, Noisy, Cooldown, and Scanning states so the current regime is easier to read at first glance.

* Improved ATR context labeling.
ATR now appears as Quiet ATR, Balanced ATR, Active ATR, or Hot ATR in the panel and right-edge tag.

* Expanded panel placement controls.
Panel location now includes top, middle, and bottom positions with left, center, and right options.

* Refined transition labels.
Labels now use readable publication-style casing, stronger spacing, and concise state text instead of dense technical wording.

* Refined reaction-zone labels.
Reaction zones keep centered premium labels with stronger contrast for dark and light chart themes.

* Tightened the default publication layout.
Major Expansion and Climax events now use the centered zone label as the primary story element when reaction zones are enabled, reducing duplicate labels around the same candles.

* Added spacing logic for reaction zones.
New reaction zones now require both bar spacing and price separation, reducing stacked boxes in the same volatility cluster.

* Refined secondary cycle labels.
Reset and Contraction labels now appear only when the cycle context is strong enough to add useful chart narrative.


------------------------
Visual Improvements
------------------------

* Reduced ribbon dominance so volatility context remains visible without overpowering candles.

* Improved chart readability by spacing labels farther away from candle bodies and wicks.

* Reduced visual clutter while keeping enough chart annotations to tell a clear volatility-cycle story.

* Refined visual hierarchy so active regime, ATR context, and reaction zones stand out more clearly.

* Adjusted centered zone labels for stronger contrast and cleaner first-glance interpretation.

* Increased default label spacing and moved the right-edge phase tag farther from the active candle cluster.

* Lightened the volatility ribbon so it supports the story without competing with candles and zones.


------------------------
Interface & Usability
------------------------

* Added full panel controls for show/hide, location, theme, and font size.

* Kept chart label and panel font-size controls with Normal as the default.

* Preserved the single merged blue panel header row for consistent AGPro Series presentation.

* Improved right-edge tag wording so current volatility state and ATR context can be read quickly.


------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

The ATR percentile, Bollinger Band width percentile, squeeze state, volume z-score, ATR rate-of-change, and phase confirmation structure remain aligned with the previous version.

The goal is to improve clarity and usability, not to introduce predictive behavior.


------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as liquidity, extreme volatility, timeframe differences, and reported volume quality may affect how regimes appear.

Outputs should always be interpreted within broader market context.


------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
ملاحظات الأخبار
UPDATE NOTES - V1.6

This update focuses on chart readability, zone-label consistency, and panel behavior.

The core purpose of the script remains unchanged.
This release improves how the existing volatility-regime logic is presented, organized, and interpreted on the chart.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.

------------------------
What Changed
------------------------

* Converted the right-edge phase tag into a no-arrow context badge.
The current phase badge no longer points toward empty chart space, making it clearer that it is a live context label rather than a zone marker.

* Improved reaction-zone object management.
Reaction zones and their centered labels are now pruned together, reducing the risk of retained zones and labels falling out of sync.

* Improved panel show / hide behavior.
The panel is now deleted when disabled and rebuilt when needed, instead of leaving a cleared table object behind.

* Preserved the existing phase engine.
The ATR percentile, BB width percentile, squeeze, volume z-score, ATR ROC, confirmation, and phase-duration logic remain unchanged.

------------------------
Visual Improvements
------------------------

* Improved chart readability by making the right-edge phase context look like a badge instead of a pointer.

* Preserved centered labels inside reaction zones.

* Reduced visual ambiguity between live context badges and actual reaction-zone labels.

* Kept the existing ribbon, transition labels, zones, and panel hierarchy intact.

------------------------
Interface & Usability
------------------------

* Updated the right-edge label input wording to better describe its badge behavior.

* Panel theme, location, and font-size controls remain available.

* Label font-size control continues to affect chart labels, zone labels, and the right-edge phase badge.

------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

The goal is to improve clarity and usability, not to introduce new predictive behavior.

Users should interpret outputs the same way as before, but with improved visual structure.

------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may affect how signals appear.

Outputs should always be interpreted within broader market context.

------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.
ملاحظات الأخبار
🔧 UPDATE NOTES - v1.7

This update surfaces the phase confidence score in the panel and adds a release-rate proof.

The core purpose of the script remains unchanged.
It continues to map Contraction, Expansion, Climax and Reset volatility phases with the same
confirmed phase engine, ribbon, reaction zones and workflow.

This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.

------------------------
What Changed
------------------------

- Phase Confidence row
The 0-100 phase confidence score now appears directly in the panel, not only on chart labels,
giving an at-a-glance read of how strongly the current phase is supported.

- Release Rate proof layer
The panel now reports how often confirmed coil releases (Contraction into Expansion) actually
expanded realized volatility within the window, shown with the sample count for transparency.

- Release Proof Window input
A new setting controls the window used to measure post-release volatility expansion.

- Honest, conservative counting
Each confirmed release is counted once, and a quick return to contraction is treated as a
non-expansion, so the rate stays realistic on the selected market and timeframe.

------------------------
Visual Improvements
------------------------

- Preserved the volatility ribbon, reaction zones and centered zone labels

- Kept transition labels controlled and clear of candles

- Maintained the no-arrow right-edge phase badge

- Left the publication-ready chart layout intact

------------------------
Interface & Usability
------------------------

- Added a Phase Confidence row for a clear score read

- Added a Release Rate row for an at-a-glance expansion track record

- Added a window setting so the proof measures prompt expansion

- Enhanced overall user experience without changing the core regime logic

------------------------
Behavior Notes
------------------------

This update does not change the core analytical logic of the script.

Phase detection, confidence and states are unchanged. The Phase Confidence row simply displays
an existing value, and the Release Rate is a separate historical track-record layer.

------------------------
Limitations Reminder
------------------------

The script remains a rule-based analytical tool.

Market conditions such as volatility, liquidity, and timeframe differences may affect how
phases, confidence and the rate appear.

Outputs should always be interpreted within broader market context.

------------------------
Risk Reminder
------------------------

This script is for educational and analytical purposes only.

It does not provide financial advice or guaranteed trading outcomes.

Users remain responsible for their own decisions.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.