OPEN-SOURCE SCRIPT
Self-Organized Criticality - Avalanche Distribution

Here's all you need to know: This indicator applies Self-Organized Criticality (SOC) theory to financial markets, measuring the power-law exponent (alpha) of price drawdown distributions. It identifies whether markets are in stable Gaussian regimes or critical states where large cascading moves become more probable.
Self-Organized Criticality
SOC theory, introduced by Per Bak, Tang, and Wiesenfeld (1987), describes how complex systems naturally evolve toward critical (fragile) states. An example is a sand pile: adding grains creates avalanches whose sizes follow a power-law distribution rather than a normal distribution.
Financial markets exhibit similar behavior. Price movements aren't purely random walks—they display:
Power-Law Distributions
When a system is in a critical state, the probability of an avalanche of size s follows:
P(s) ∝ s^(-α)
Where:
This indicator estimates α from the empirical distribution of price drawdowns.
Mathematical Method
1. Avalanche Detection
The indicator identifies local price peaks (highest point in a lookback window), then measures the percentage drawdown to the next trough. A dynamic ATR-based threshold filters out noise—small drops in calm markets count, but the bar rises in volatile periods.
2. Logarithmic Binning
Avalanche sizes are sorted into logarithmically-spaced bins (e.g., 1-2%, 2-4%, 4-8%) rather than linear bins. This captures power-law behavior across multiple scales - a 2% drop and 20% crash both matter. The indicator creates 12 adaptive bins spanning from your smallest to largest observed avalanche.
3. Bin-to-Bin Ratio Estimation
For each pair of adjacent bins, we calculate:
α ≈ log(N₁/N₂) / log(s₂/s₁)
Where N₁ and N₂ are avalanche counts, s₁ and s₂ are bin sizes.
Example: If 2% drops happen 4× more often than 4% drops, then α ≈ log(4)/log(2) ≈ 2.0.
We get 8-11 independent estimates and average them. This is more robust than fitting one line through all points—outliers can't dominate.
4. Rolling Window Analysis
Alpha recalculates using only recent avalanches (default: last 500 bars). Old data drops out as new avalanches occur, so the indicator tracks regime shifts in real-time.
Regime Classification
🟢 Gaussian α ≥ 2.8 Normal distribution behavior; large moves are rare outliers
🟡 Transitional 1.8 ≤ α < 2.8 Moderate fat tails; system approaching criticality
🟠 Critical 1.0 ≤ α < 1.8 Heavy tails; large avalanches increasingly common
🔴 Super-Critical α < 1.0 Extreme tail risk; system prone to cascading failures
What Alpha Tells You
Supporting Metrics
Limitations
This is a distributional measure, not a timing indicator. Low alpha indicates increased systemic risk but doesn't predict when a cascade will occur. Only that the probability distribution has shifted toward larger events.
How This Differs from the Per Bak Fragility Index
The SOC Avalanche Distribution calculates the power-law exponent (alpha) directly from price drawdown distributions - a pure mathematical analysis requiring only price data. The Per Bak Fragility Index aggregates external stress indicators (VIX, SKEW, credit spreads, put/call ratios) into a weighted composite score.
Technical Notes
References
Bak, P., Tang, C., & Wiesenfeld, K. (1987). Self-organized criticality: An explanation of the 1/f noise. Physical Review Letters.
Sornette, D. (2003). Why Stock Markets Crash: Critical Events in Complex Financial Systems. Princeton University Press.
Self-Organized Criticality
SOC theory, introduced by Per Bak, Tang, and Wiesenfeld (1987), describes how complex systems naturally evolve toward critical (fragile) states. An example is a sand pile: adding grains creates avalanches whose sizes follow a power-law distribution rather than a normal distribution.
Financial markets exhibit similar behavior. Price movements aren't purely random walks—they display:
- Fat-tailed distributions (more extreme events than Gaussian models predict)
- Scale invariance (no characteristic avalanche size)
- Intermittent dynamics (periods of calm punctuated by large cascades)
Power-Law Distributions
When a system is in a critical state, the probability of an avalanche of size s follows:
P(s) ∝ s^(-α)
Where:
- α (alpha) is the power-law exponent
- Higher α → distribution resembles Gaussian (large events rare)
- Lower α → heavy tails dominate (large events common)
This indicator estimates α from the empirical distribution of price drawdowns.
Mathematical Method
1. Avalanche Detection
The indicator identifies local price peaks (highest point in a lookback window), then measures the percentage drawdown to the next trough. A dynamic ATR-based threshold filters out noise—small drops in calm markets count, but the bar rises in volatile periods.
2. Logarithmic Binning
Avalanche sizes are sorted into logarithmically-spaced bins (e.g., 1-2%, 2-4%, 4-8%) rather than linear bins. This captures power-law behavior across multiple scales - a 2% drop and 20% crash both matter. The indicator creates 12 adaptive bins spanning from your smallest to largest observed avalanche.
3. Bin-to-Bin Ratio Estimation
For each pair of adjacent bins, we calculate:
α ≈ log(N₁/N₂) / log(s₂/s₁)
Where N₁ and N₂ are avalanche counts, s₁ and s₂ are bin sizes.
Example: If 2% drops happen 4× more often than 4% drops, then α ≈ log(4)/log(2) ≈ 2.0.
We get 8-11 independent estimates and average them. This is more robust than fitting one line through all points—outliers can't dominate.
4. Rolling Window Analysis
Alpha recalculates using only recent avalanches (default: last 500 bars). Old data drops out as new avalanches occur, so the indicator tracks regime shifts in real-time.
Regime Classification
🟢 Gaussian α ≥ 2.8 Normal distribution behavior; large moves are rare outliers
🟡 Transitional 1.8 ≤ α < 2.8 Moderate fat tails; system approaching criticality
🟠 Critical 1.0 ≤ α < 1.8 Heavy tails; large avalanches increasingly common
🔴 Super-Critical α < 1.0 Extreme tail risk; system prone to cascading failures
What Alpha Tells You
- Declining alpha → Market moving toward criticality; tail risk increasing
- Rising alpha → Market stabilizing; returns to normal distribution
- Persistent low alpha → Sustained fragility; heightened crash probability
Supporting Metrics
- Heavy Tail %: Concentration of total drawdown in largest 10% of events
- Populated Bins: Data coverage quality (11-12 out of 12 is ideal)
- Avalanche Count: Sample size for statistical reliability
Limitations
This is a distributional measure, not a timing indicator. Low alpha indicates increased systemic risk but doesn't predict when a cascade will occur. Only that the probability distribution has shifted toward larger events.
How This Differs from the Per Bak Fragility Index
The SOC Avalanche Distribution calculates the power-law exponent (alpha) directly from price drawdown distributions - a pure mathematical analysis requiring only price data. The Per Bak Fragility Index aggregates external stress indicators (VIX, SKEW, credit spreads, put/call ratios) into a weighted composite score.
Technical Notes
- Default settings optimized for daily and weekly timeframes on major indices
- Requires minimum 200 bars of history for stable estimates
- ATR-based dynamic sizing prevents scale-dependent bias
- Alerts available for regime transitions and super-critical entry
References
Bak, P., Tang, C., & Wiesenfeld, K. (1987). Self-organized criticality: An explanation of the 1/f noise. Physical Review Letters.
Sornette, D. (2003). Why Stock Markets Crash: Critical Events in Complex Financial Systems. Princeton University Press.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.