OPEN-SOURCE SCRIPT
AetherEdge - Gaussian Mixture Regimes

🖊️ Overview
AE-GMM is a self-evolving regime detector that treats the market as a probability distribution rather than carving it up with rigid rules. It models the joint distribution of momentum × volatility as a mixture of K Gaussian components — one per regime — and keeps learning their means, variances, and weights through online Expectation-Maximization with forgetting. Every bar receives a soft probability vector (a posterior) over regimes, rendered as a flowing probability ribbon that lets the market's state blend and shift before your eyes.
🔶 Key Features
Gaussian mixture + online EM engine — the E-step (responsibilities) and M-step (sufficient statistics) run every bar, estimating the regime distribution incrementally.
Self-evolving forgetting mechanism — a forgetting factor λ weights recent data, so the model quietly reshapes itself as regimes emerge and dissolve.
Soft probability ribbon — the K regime probabilities, stacked into a flow in the lower pane; not hard boundaries, but "how much of each regime is present now."
Semantic regime coloring — each component is auto-colored by the character of its learned centroid (Risk-On / Range / Risk-Off / Stress), sidestepping the label-switching problem.
Projection onto price — force_overlay tints the main chart's background by the dominant regime, deepening with confidence.
Live statistics panel — dominant regime, confidence, per-regime probabilities, regime duration, the adaptation factor λ, and model fit (log-likelihood).
Diagonal-covariance robustness — no matrix inversion, numerically stable; learning on confirmed bars only, with no look-ahead.
🧠 Technical Architecture
The feature space is two-dimensional — a momentum axis (z-scored ATR-unit trend deviation) and a volatility axis (z-scored log realized-volatility). Each component is a diagonal-covariance Gaussian with mean μ_k, variance σ²_k, and weight π_k. Every bar, responsibilities (posteriors) are computed as γ_k(x) = π_k·N(x|μ_k,σ²_k) / Σ_j π_j·N(x|μ_j,σ²_j), normalized stably via log-sum-exp in the log domain.
Learning proceeds by incremental EM. On each confirmed bar, the sufficient statistics (responsibility mass N_k, Σγx, Σγx²) are updated with a forgetting factor λ, and π_k, μ_k, σ²_k are re-derived from them. Lower λ weights recent data and adapts quickly; higher λ acts as longer memory and stays steady. Components are initialized spread around a ring in feature space, starting from diverse regimes and migrating toward the data. Each regime's color is decided every bar from its learned centroid (high volatility → Stress; positive momentum → Risk-On; negative → Risk-Off; in between → Range).
🎯 Three design choices stand out. First, soft responsibilities let regime transitions be expressed as a blend of probabilities — the "in-between" is visible. Second, character-based coloring keeps colors meaningful regardless of index shuffling. Third, confining parameter updates to confirmed bars — with only the forming bar's posterior updating live — keeps historical output non-repainting.
⚙️ Recommended Settings & Tuning Guide
As a crypto starting point — BTC/ETH (1D, 4H): K = 3, λ = 0.99, standardization length 200, vol length 20; Risk-On / Range / Stress separate cleanly. High-volatility names (SOL, XRP): lower λ toward 0.97 for faster adaptation, and set K = 4 to split Stress into upside vs downside stress, revealing the internal structure of rough action.
Per parameter: λ (adaptation) is the key knob — near 0.999 regimes are smooth and persistent; near 0.95 they switch nimbly. K (regimes) ranges from 2 (on/off) to 4 (finer states). Standardization length sets the feature baseline window — longer is steadier, shorter more locally adaptive. Stress Vol (z) sets how much of a volatility rise counts as "Stress."
💡 How to Use in Practice
The core read is dominant regime × confidence. When the ribbon is thick in a single color (high confidence) and stable, strategies aligned with that regime tend to work (trend-following in Risk-On, fading in Range). When ribbon colors blend, it signals a regime transition — a cue to cut size or stand aside. When the Stress (amber) probability rises, volatility is expanding — useful for staging breakouts or de-risking.
For multi-timeframe work, read the higher-timeframe regime for the backdrop and execute on a lower timeframe. With the price-chart background tint enabled, regime "epochs" sit directly over the candles, making context easy to combine with trend or volume tools.
⚠️ Important Notes
Regimes are hidden until the warmup period (default 200 bars) completes. Reloading the indicator, or changing settings, makes the model relearn across the entire history from scratch — learning state is not persisted. This is a diagonal-covariance approximation and does not explicitly model correlation between features. Regime probabilities are the model's probabilistic beliefs, not certain forecasts. Parameters update on confirmed bars, while the forming bar's probabilities move live.
🚨 Disclaimer
This indicator is for educational and informational purposes only and does not constitute financial or investment advice. Past performance is not indicative of future results. All trading involves risk. Use it alongside your own thorough testing and sound risk management; all trading decisions remain solely your own responsibility.
AE-GMM is a self-evolving regime detector that treats the market as a probability distribution rather than carving it up with rigid rules. It models the joint distribution of momentum × volatility as a mixture of K Gaussian components — one per regime — and keeps learning their means, variances, and weights through online Expectation-Maximization with forgetting. Every bar receives a soft probability vector (a posterior) over regimes, rendered as a flowing probability ribbon that lets the market's state blend and shift before your eyes.
🔶 Key Features
Gaussian mixture + online EM engine — the E-step (responsibilities) and M-step (sufficient statistics) run every bar, estimating the regime distribution incrementally.
Self-evolving forgetting mechanism — a forgetting factor λ weights recent data, so the model quietly reshapes itself as regimes emerge and dissolve.
Soft probability ribbon — the K regime probabilities, stacked into a flow in the lower pane; not hard boundaries, but "how much of each regime is present now."
Semantic regime coloring — each component is auto-colored by the character of its learned centroid (Risk-On / Range / Risk-Off / Stress), sidestepping the label-switching problem.
Projection onto price — force_overlay tints the main chart's background by the dominant regime, deepening with confidence.
Live statistics panel — dominant regime, confidence, per-regime probabilities, regime duration, the adaptation factor λ, and model fit (log-likelihood).
Diagonal-covariance robustness — no matrix inversion, numerically stable; learning on confirmed bars only, with no look-ahead.
🧠 Technical Architecture
The feature space is two-dimensional — a momentum axis (z-scored ATR-unit trend deviation) and a volatility axis (z-scored log realized-volatility). Each component is a diagonal-covariance Gaussian with mean μ_k, variance σ²_k, and weight π_k. Every bar, responsibilities (posteriors) are computed as γ_k(x) = π_k·N(x|μ_k,σ²_k) / Σ_j π_j·N(x|μ_j,σ²_j), normalized stably via log-sum-exp in the log domain.
Learning proceeds by incremental EM. On each confirmed bar, the sufficient statistics (responsibility mass N_k, Σγx, Σγx²) are updated with a forgetting factor λ, and π_k, μ_k, σ²_k are re-derived from them. Lower λ weights recent data and adapts quickly; higher λ acts as longer memory and stays steady. Components are initialized spread around a ring in feature space, starting from diverse regimes and migrating toward the data. Each regime's color is decided every bar from its learned centroid (high volatility → Stress; positive momentum → Risk-On; negative → Risk-Off; in between → Range).
🎯 Three design choices stand out. First, soft responsibilities let regime transitions be expressed as a blend of probabilities — the "in-between" is visible. Second, character-based coloring keeps colors meaningful regardless of index shuffling. Third, confining parameter updates to confirmed bars — with only the forming bar's posterior updating live — keeps historical output non-repainting.
⚙️ Recommended Settings & Tuning Guide
As a crypto starting point — BTC/ETH (1D, 4H): K = 3, λ = 0.99, standardization length 200, vol length 20; Risk-On / Range / Stress separate cleanly. High-volatility names (SOL, XRP): lower λ toward 0.97 for faster adaptation, and set K = 4 to split Stress into upside vs downside stress, revealing the internal structure of rough action.
Per parameter: λ (adaptation) is the key knob — near 0.999 regimes are smooth and persistent; near 0.95 they switch nimbly. K (regimes) ranges from 2 (on/off) to 4 (finer states). Standardization length sets the feature baseline window — longer is steadier, shorter more locally adaptive. Stress Vol (z) sets how much of a volatility rise counts as "Stress."
💡 How to Use in Practice
The core read is dominant regime × confidence. When the ribbon is thick in a single color (high confidence) and stable, strategies aligned with that regime tend to work (trend-following in Risk-On, fading in Range). When ribbon colors blend, it signals a regime transition — a cue to cut size or stand aside. When the Stress (amber) probability rises, volatility is expanding — useful for staging breakouts or de-risking.
For multi-timeframe work, read the higher-timeframe regime for the backdrop and execute on a lower timeframe. With the price-chart background tint enabled, regime "epochs" sit directly over the candles, making context easy to combine with trend or volume tools.
⚠️ Important Notes
Regimes are hidden until the warmup period (default 200 bars) completes. Reloading the indicator, or changing settings, makes the model relearn across the entire history from scratch — learning state is not persisted. This is a diagonal-covariance approximation and does not explicitly model correlation between features. Regime probabilities are the model's probabilistic beliefs, not certain forecasts. Parameters update on confirmed bars, while the forming bar's probabilities move live.
🚨 Disclaimer
This indicator is for educational and informational purposes only and does not constitute financial or investment advice. Past performance is not indicative of future results. All trading involves risk. Use it alongside your own thorough testing and sound risk management; all trading decisions remain solely your own responsibility.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.