Volatility State Index [Interakktive]The Volatility State Index (VSI) classifies market volatility into three behavioral states: Expansion, Decay, and Transition. It answers one question visually: Is volatility supporting price movement, withdrawing, or unstable?
Unlike traditional volatility indicators that show levels or bands, VSI diagnoses the current volatility regime so traders can adapt their approach accordingly.
█ WHAT IT DOES
• Classifies volatility into three states: Expansion (teal), Decay (grey), Transition (amber)
• Measures volatility momentum as a percentage rate-of-change
• Applies stability filtering to detect unstable/choppy conditions
• Uses persistence logic to prevent state flickering
• Exports state data for use in alerts and strategies
█ WHAT IT DOES NOT DO
• NO buy/sell signals
• NO entry/exit recommendations
• NO alerts (v1 is diagnostic only)
• NO performance claims
This is a volatility diagnostic tool, not a trading system.
█ HOW IT WORKS
The VSI processes volatility through a five-stage pipeline:
STAGE 1 — Base Volatility
Calculates ATR as the foundation for volatility measurement.
STAGE 2 — Smoothing
Applies EMA smoothing to reduce noise in the volatility series.
STAGE 3 — Volatility Momentum
Computes the percentage rate-of-change of smoothed volatility:
Volatility Momentum (%) = ((Current ATR - Previous ATR) / Previous ATR) × 100
Positive values indicate expanding volatility; negative values indicate contracting volatility.
STAGE 4 — Stability Filter
Tracks how frequently volatility momentum changes direction. Frequent sign changes indicate unstable, choppy conditions.
Stability Score = 1 - (Average Flip Rate)
Low stability forces the Transition state regardless of momentum level.
STAGE 5 — State Classification
Combines momentum thresholds and stability to determine the final state:
• Expansion: Momentum ≥ +5% (default threshold)
• Decay: Momentum ≤ -5% (default threshold)
• Transition: Between thresholds OR low stability
A persistence filter requires states to hold for multiple bars before confirming, preventing visual noise.
█ INTERPRETATION
EXPANSION (Teal)
Volatility is increasing in a sustained way. Price moves are becoming larger.
What it suggests:
• Breakouts are more likely to follow through
• Stops may need wider placement
• Trend-following approaches tend to work better
• Mean-reversion weakens
DECAY (Grey)
Volatility is decreasing. Price is compressing into tighter ranges.
What it suggests:
• Breakouts are more likely to fail
• Ranges tend to hold
• Trend-following underperforms
• Mean-reversion strengthens
TRANSITION (Amber)
Volatility behavior is unclear or unstable. This is NOT neutral — it is uncertainty.
What it suggests:
• Mixed signals — one bar huge, next bar dead
• Higher whipsaw risk
• Reduced conviction in either direction
• Consider waiting for clarity
The key insight: Amber is a warning, not a middle ground. It appears when volatility cannot decide what it wants to do.
█ VISUAL DESIGN
The indicator uses a state-first histogram design:
• Histogram height shows volatility momentum percentage
• Histogram color shows the classified state
• Zero line provides visual anchor
• Optional momentum line for confirmation
• Optional background tint (default OFF for clean charts)
The visual hierarchy prioritizes instant state recognition. A trader should understand the volatility environment in under one second without reading numbers.
█ INPUTS
Core Settings
• ATR Length: Base volatility measurement period (default: 14)
• Smoothing Length: EMA smoothing applied to ATR (default: 10)
• Momentum Length: Rate-of-change lookback (default: 10)
State Classification
• Expansion Threshold (%): Momentum above this = Expansion (default: 5.0)
• Decay Threshold (%): Momentum below this = Decay (default: -5.0)
• Persistence Bars: Bars required to confirm state change (default: 3)
• Stability Lookback: Window for stability calculation (default: 20)
• Stability Threshold: Below this = forced Transition (default: 0.5)
Visual Settings
• Show State Histogram: Toggle main display (default: ON)
• Show Momentum Line: Thin confirmation line (default: OFF)
• Show Zero Line: Baseline reference (default: ON)
• Show Background Tint: Subtle state coloring (default: OFF)
█ DATA WINDOW EXPORTS
When enabled, the following values are exported:
• ATR (Raw)
• ATR (Smoothed)
• Volatility Momentum (%)
• Stability Score (0-1)
• State (-1/0/1): Decay = -1, Transition = 0, Expansion = 1
• Is Expansion (0/1)
• Is Decay (0/1)
• Is Transition (0/1)
These exports allow VSI to be used as a filter in Pine Script strategies or alert conditions.
█ ORIGINALITY
While ATR and volatility indicators are common, VSI is original because it:
1. Classifies volatility into behavioral states rather than showing raw levels
2. Applies momentum analysis to volatility itself (rate-of-change of ATR)
3. Uses stability filtering to detect genuinely unstable conditions
4. Implements persistence logic to prevent state flickering
5. Provides a state-first visual design optimized for instant recognition
VSI is state-first: it classifies volatility regimes (Expansion/Decay/Transition) rather than plotting volatility level alone, using momentum and stability to reduce false regime reads.
This is not a modified ATR or Bollinger Band — it is a volatility regime classifier.
█ SUITABLE MARKETS
Works on: Stocks, Futures, Forex, Crypto
Timeframes: All timeframes — state classification adapts accordingly
Best on: Instruments with consistent volatility patterns
█ RELATED
• Market Efficiency Ratio — measures price path efficiency
• Effort-Result Divergence — compares volume effort to price result
█ DISCLAIMER
This indicator is for educational purposes only. It does not constitute financial advice. Past performance does not guarantee future results. Always conduct your own analysis before making trading decisions.
State
lib_statemachine_modifiedLibrary "lib_statemachine_modified"
Modified to fix bugs and create getState and priorState methods.
method step(this, before, after, condition)
Namespace types: StateMachine
Parameters:
this (StateMachine)
before (int) : (int): Current state before transition
after (int) : (int): State to transition to
condition (bool) : (bool): Condition to trigger the transition
Returns: (bool): True if the state changed, else False
method step(this, after, condition)
Namespace types: StateMachine
Parameters:
this (StateMachine)
after (int) : (int): State to transition to
condition (bool) : (bool): Condition to trigger the transition
Returns: (bool): True if the state changed, else False
method currentState(this)
Namespace types: StateMachine
Parameters:
this (StateMachine)
method previousState(this)
Namespace types: StateMachine
Parameters:
this (StateMachine)
method changed(this, within_bars)
Namespace types: StateMachine
Parameters:
this (StateMachine)
within_bars (int) : (int): Number of bars to look back for a state change
Returns: (bool): True if a state change occurred within the timeframe, else False
method reset(this, condition, min_occurrences)
Namespace types: StateMachine
Parameters:
this (StateMachine)
condition (bool) : (bool): Condition to trigger the reset
min_occurrences (int) : (int): Minimum number of times the condition must be true to reset
Returns: (bool): True if the state was reset, else False
StateMachine
Fields:
state (series int)
neutral (series int)
enabled (series bool)
reset_counter (series int)
prior_state (series int)
last_change_bar (series int)
Correlation Cycle, CorrelationAngle, Market State - John EhlersHot off the press, I present this "Correlation Cycle, CorrelationAngle, and Market State" multicator employing PSv4.0, originally formulated by Dr. John Ehlers for TASC - June 2020 Traders Tips. Basically it's an all-in-one combination of three Ehlers' indicators. This power packed triplet indicator, being less than a 100 line implementation at initial release, is a heavily modified version of the original indicator using novel techniques that surpass John Ehlers' original intended design.
This is also a profound script in numerous ways. First of all, these three indicators are directly from the illustrious mastermind himself Dr. John Ehlers. Secondarily, this is my "50th" script published on TV, which makes it even more significant. I'm especially proud of this script to "degrees" of imagination I once didn't know was theoretically possible in code. My intellect has once again been mathemagically unlocked pondering new innovations with this code revelation. Thirdly, this PSv4.0 script shows the empowering beauty and elegance of hacking the stock markets with TV's ultra utilitarian Pine Editor(PE) in a common browser! Some of you may be wondering if I worked on this for days... nope! This only took a few hours, followed by writing this description for another hour plus.
I have created many of Ehlers' indicators in PE, a few of which I have published in my profile, but I wanted to show how programming with Pine Script can be an artistic form of craftsmanship and poetry. None of this would be possible without the ingeniously minded Tradingview staff revolutionizing algorithmic trading at it's finest. If you should ever encounter them by chance, ponder humbly thanking these computing wizards for their diligence and dedication. They are providing, and shall award to us members, some of the most fascinating conceptualized tech imaginable in the coming future. I can assure you, much, much more is yet to be unveiled for us TV members/enthusiasts. Thank you TV and all you offer to this community.
As always, I have included advanced Pine programming techniques that conform to proper "Pine Etiquette" by example. There are so many Pine mastery techniques included, I don't have an abundance of time to elaborate on all of them. For those of you are code savvy, you may have notice I only used one "for" loop for increased server efficiency, instead of the two "for" loops in the original formulation. For those of you who are newcomers to Pine Script, this code release may also help you comprehend the immense "Power of Pine" by employing advanced programming techniques while exhibiting code utilization in a most effective manner. This is commonly what my dense intricate code looks like behind the veil. If you are wondering why there is hardly any notes, that's because the notation is primarily in the variable naming.
Features List Includes:
Dark Background - Easily disabled in indicator Settings->Style for "Light" charts or with Pine commenting
AND a few more... Why list them, when you have the source code!
The comments section below is solely just for commenting and other remarks, ideas, compliments, etc... regarding only this indicator, not others. When available time provides itself, I will consider your inquiries, thoughts, and concepts presented below in the comments section, should you have any questions or comments regarding this indicator. When my indicators achieve more prevalent use by TV members, I may implement more ideas when they present themselves as worthy additions. As always, "Like" it if you simply just like it with a proper thumbs up, and also return to my scripts list occasionally for additional postings. Have a profitable future everyone!


