OPEN-SOURCE SCRIPT
Entropy Balance Oscillator [JOAT]

Entropy Balance Oscillator - Chaos Theory Edition
Overview
Entropy Balance Oscillator is an open-source oscillator indicator that applies chaos theory concepts to market analysis. It calculates market entropy (disorder/randomness), balance (price position within range), and various chaos metrics to identify whether the market is in an ordered, chaotic, or balanced state. This helps traders understand market regime and adjust their strategies accordingly.
What This Indicator Does
The indicator calculates and displays:
- Entropy - Measures market disorder using return distribution analysis
- Balance - Price position within the high-low range, normalized to -1 to +1
- Lyapunov Exponent - Estimates sensitivity to initial conditions (chaos indicator)
- Hurst Exponent - Measures long-term memory in price series (trend persistence)
- Strange Attractor - Simulated attractor points for visualization
- Bifurcation Detection - Identifies potential regime change points
- Chaos Index - Combined entropy and volatility score
- Market Phase - Classification as CHAOS, ORDER, or BALANCED
How It Works
Entropy is calculated using return distribution:
calculateEntropy(series float price, simple int period) =>
// Calculate returns and their absolute values
// Sum absolute returns for normalization
// Apply Shannon entropy formula: -sum(p * log(p))
float entropy = 0.0
for i = 0 to array.size(returns) - 1
float prob = math.abs(array.get(returns, i)) / sumAbs
if prob > 0
entropy -= prob * math.log(prob)
entropy
Balance measures price position within range:
calculateBalance(series float high, series float low, series float close, simple int period) =>
float range = high - low
float position = (close - low) / (range > 0 ? range : 1)
float balance = ta.ema(position, period)
(balance - 0.5) * 2 // Normalize to -1 to +1
Lyapunov Exponent estimates chaos sensitivity:
lyapunovExponent(series float price, simple int period) =>
float sumLog = 0.0
for i = 1 to period
float ratio = price[i - 1] > 0 ? math.abs(price / price[i - 1]) : 1.0
if ratio > 0
sumLog += math.log(ratio)
lyapunov := sumLog / period
Hurst Exponent measures trend persistence:
- H > 0.5: Trending/persistent behavior
- H = 0.5: Random walk
- H < 0.5: Mean-reverting behavior
Signal Generation
Phase changes and extreme conditions generate signals:
- Chaos Phase: Normalized entropy exceeds chaos threshold (default 0.7)
- Order Phase: Normalized entropy falls below order threshold (default 0.3)
- Extreme Chaos: Entropy exceeds 1.5x chaos threshold
- Extreme Order: Entropy falls below 0.5x order threshold
- Bifurcation: Variance exceeds 2x average variance
Dashboard Panel (Top-Right)
- Market Phase - Current phase (CHAOS/ORDER/BALANCED)
- Entropy Level - Normalized entropy value
- Balance - Current balance reading (-1 to +1)
- Chaos Index - Combined chaos score percentage
- Volatility - Current price volatility
- Lyapunov Exp - Lyapunov exponent value
- Hurst Exponent - Hurst exponent value
- Chaos Score - Overall chaos assessment
- Status - Current market status
Visual Elements
- Entropy Line - Main oscillator showing normalized entropy
- Entropy EMA - Smoothed entropy for trend reference
- Balance Area - Filled area showing balance direction
- Chaos/Order Thresholds - Horizontal dashed lines
- Lyapunov Line - Step line showing Lyapunov exponent
- Strange Attractor - Circle plots showing attractor points
- Phase Space - Line showing phase space reconstruction
- Phase Background - Background color based on current phase
- Extreme Markers - X-cross for extreme chaos, diamond for extreme order
- Bifurcation Markers - Circles at potential regime changes
Input Parameters
- Entropy Period (default: 20) - Period for entropy calculation
- Balance Period (default: 14) - Period for balance calculation
- Chaos Threshold (default: 0.7) - Threshold for chaos phase
- Order Threshold (default: 0.3) - Threshold for order phase
- Lyapunov Exponent (default: true) - Enable Lyapunov calculation
- Hurst Exponent (default: true) - Enable Hurst calculation
- Strange Attractor (default: true) - Enable attractor visualization
- Bifurcation Detection (default: true) - Enable bifurcation detection
Suggested Use Cases
- Identify market regime for strategy selection (trend-following vs mean-reversion)
- Watch for phase changes as potential trading environment shifts
- Use Hurst exponent to assess trend persistence
- Monitor chaos index for volatility regime awareness
- Avoid trading during extreme chaos phases
Timeframe Recommendations
Best on 1H to Daily charts. Chaos metrics require sufficient data for meaningful calculations.
Limitations
- Chaos theory concepts are applied as analogies, not rigorous mathematical implementations
- Lyapunov and Hurst calculations are simplified approximations
- Strange attractor visualization is conceptual
- Bifurcation detection uses variance as proxy
Open-Source and Disclaimer
This script is published as open-source under the Mozilla Public License 2.0 for educational purposes. It does not constitute financial advice. Past performance does not guarantee future results. Always use proper risk management.
- Made with passion by officialjackofalltrades
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
#1 Full Stack AI Trading Community — jackofalltrades.vip | 2026: The Era of AI Trading Mastery📈 AI Automation • AI Trading Bots • Indicators • Strategies • Limitless Potential • Institutional Grade Products • t.me/jackofalltradesvip
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
#1 Full Stack AI Trading Community — jackofalltrades.vip | 2026: The Era of AI Trading Mastery📈 AI Automation • AI Trading Bots • Indicators • Strategies • Limitless Potential • Institutional Grade Products • t.me/jackofalltradesvip
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。