OPEN-SOURCE SCRIPT
AetherEdge - Autoencoder Anomaly

🖊️ Overview
AE-ANO is a self-evolving detector of market dislocations. It turns the current bar's state into a feature vector and passes it through a linear autoencoder — compress to a narrow bottleneck, decode back — with weights trained online by gradient descent to minimize reconstruction error on normal structure. Once it has learned the normal manifold, a bar that breaks the usual relationships between features (a flash move, a structure break, a shock) cannot be reconstructed well — a high reconstruction error = an anomaly. The error is standardized into a sigma score, a Mahalanobis-style distance flags magnitude outliers, and the most dislocated feature is named.
🔶 Key Features
Linear autoencoder engine — compresses and reconstructs a 6-dimensional state vector, measuring deviation from normal via reconstruction error.
Self-evolving online learning — encoder/decoder weights learn by gradient descent, continually updating the definition of "normal" to the market.
Reconstruction-error thermometer — the anomaly score (σ) over time as a neon-gradient filled area (calm → hot).
Anomaly pulses — bars whose score exceeds the threshold are marked on price with a glowing marker and background flash (intensity scales with magnitude).
Mahalanobis distance — a Euclidean distance in standardized space flags magnitude outliers (distance from center), complementing the autoencoder.
Feature panel — colors which feature (return/vol/range/body/momentum/trend) is dislocated and names the lead driver.
Live statistics panel — anomaly score, reconstruction error, Mahalanobis distance, lead feature, bottleneck, and last anomaly.
Non-repainting design — learning on confirmed bars only; each bar is judged against what was learned before it, with no look-ahead.
🧠 Technical Architecture
The feature vector is six standardized features — return, volatility (log squared return), range expansion, body/candle character, momentum (RSI), and trend deviation. On each confirmed bar, a forward pass with the current weights (learned through t−1) computes code = We·x (encode), x̂ = Wd·code (decode), and err = x − x̂, giving the reconstruction error ‖err‖. This is standardized by the error's EMA mean and standard deviation into a sigma score (err − mean)/std. After judging, the encoder and decoder weights are updated by backprop SGD (stabilized with weight decay and clipping).
This "judge-then-learn" order flags one-off anomalies before they're absorbed into normal. Yet if an anomaly persists, the weights learn the new structure — adapting to a non-stationary market (the self-evolution). The Mahalanobis-style distance is ‖x‖ in standardized space (distance from the normal center, expected ≈ √D under normality), measuring magnitude outliers to complement the autoencoder (which captures correlation-breaking, structural anomalies). The lead feature is the dimension with the largest reconstruction error — showing what is dislocated now.
🎯 Three design choices stand out. First, the linear autoencoder learns the usual correlations between features and flags bars that break them (e.g., a large move with no accompanying range) as high error. Second, standardizing the error into σ enables an instrument-independent threshold. Third, judging before learning and confining updates to confirmed bars keeps historical anomaly scores non-repainting.
⚙️ Recommended Settings & Tuning Guide
As a crypto starting point — BTC/ETH (1D, 4H): bottleneck 2, learning rate 0.02, standardization length 100, error window 100, threshold 2.5σ; flash moves and structure breaks are clearly marked. High-volatility names (SOL, XRP): raise the learning rate toward 0.03 for faster adaptation, and the threshold to 3.0σ to catch only genuine anomalies amid normal volatility. For more sensitivity, set the bottleneck to 1 (a tighter normal manifold) and the threshold to 2.0σ.
Per parameter: Bottleneck (k) sets sensitivity — smaller defines "normal" more tightly and is more sensitive to deviation. Learning rate sets adaptation speed (higher is nimbler but too high destabilizes). Standardization length sets the feature baseline. Error window sets the anomaly-score baseline (shorter is more locally adaptive). Threshold (σ) sets pulse sensitivity.
💡 How to Use in Practice
The core read is anomaly score × lead feature. While the score stays calm (NORMAL), the market is within its learned normal structure — existing logic tends to work. The moment the score spikes above the threshold (pulse fires) signals structure has temporarily broken — the start of a breakout, a liquidity shock, a flash move, or a news reaction. The lead feature tells you what is anomalous (e.g., a spike with no volume shows up as Body/Range), helping characterize it. The EXTREME level marks especially strong dislocations — a cue for risk management (revisit stops, cut size).
For multi-timeframe work, read higher-timeframe anomalies for major structure breaks and time execution on a lower timeframe. Because it shows when structure breaks (not direction), pair it with trend or directional signals (e.g., avoid trend-following during anomalies).
⚠️ Important Notes
Nothing displays until the warmup period (default 150 bars) completes. Reloading the indicator retrains the weights from scratch — learning state is not persisted. This is a linear autoencoder and does not fully capture nonlinear normal structure (reconstruction error measures deviation from a linear manifold). If an anomaly persists, it is by design learned as the new "normal" (adaptation to non-stationarity). The Mahalanobis distance is a simplified version assuming diagonal covariance (Euclidean in standardized space). The anomaly score shows no direction, only structural breakage. Judging precedes learning, and updates occur on confirmed bars only.
🚨 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-ANO is a self-evolving detector of market dislocations. It turns the current bar's state into a feature vector and passes it through a linear autoencoder — compress to a narrow bottleneck, decode back — with weights trained online by gradient descent to minimize reconstruction error on normal structure. Once it has learned the normal manifold, a bar that breaks the usual relationships between features (a flash move, a structure break, a shock) cannot be reconstructed well — a high reconstruction error = an anomaly. The error is standardized into a sigma score, a Mahalanobis-style distance flags magnitude outliers, and the most dislocated feature is named.
🔶 Key Features
Linear autoencoder engine — compresses and reconstructs a 6-dimensional state vector, measuring deviation from normal via reconstruction error.
Self-evolving online learning — encoder/decoder weights learn by gradient descent, continually updating the definition of "normal" to the market.
Reconstruction-error thermometer — the anomaly score (σ) over time as a neon-gradient filled area (calm → hot).
Anomaly pulses — bars whose score exceeds the threshold are marked on price with a glowing marker and background flash (intensity scales with magnitude).
Mahalanobis distance — a Euclidean distance in standardized space flags magnitude outliers (distance from center), complementing the autoencoder.
Feature panel — colors which feature (return/vol/range/body/momentum/trend) is dislocated and names the lead driver.
Live statistics panel — anomaly score, reconstruction error, Mahalanobis distance, lead feature, bottleneck, and last anomaly.
Non-repainting design — learning on confirmed bars only; each bar is judged against what was learned before it, with no look-ahead.
🧠 Technical Architecture
The feature vector is six standardized features — return, volatility (log squared return), range expansion, body/candle character, momentum (RSI), and trend deviation. On each confirmed bar, a forward pass with the current weights (learned through t−1) computes code = We·x (encode), x̂ = Wd·code (decode), and err = x − x̂, giving the reconstruction error ‖err‖. This is standardized by the error's EMA mean and standard deviation into a sigma score (err − mean)/std. After judging, the encoder and decoder weights are updated by backprop SGD (stabilized with weight decay and clipping).
This "judge-then-learn" order flags one-off anomalies before they're absorbed into normal. Yet if an anomaly persists, the weights learn the new structure — adapting to a non-stationary market (the self-evolution). The Mahalanobis-style distance is ‖x‖ in standardized space (distance from the normal center, expected ≈ √D under normality), measuring magnitude outliers to complement the autoencoder (which captures correlation-breaking, structural anomalies). The lead feature is the dimension with the largest reconstruction error — showing what is dislocated now.
🎯 Three design choices stand out. First, the linear autoencoder learns the usual correlations between features and flags bars that break them (e.g., a large move with no accompanying range) as high error. Second, standardizing the error into σ enables an instrument-independent threshold. Third, judging before learning and confining updates to confirmed bars keeps historical anomaly scores non-repainting.
⚙️ Recommended Settings & Tuning Guide
As a crypto starting point — BTC/ETH (1D, 4H): bottleneck 2, learning rate 0.02, standardization length 100, error window 100, threshold 2.5σ; flash moves and structure breaks are clearly marked. High-volatility names (SOL, XRP): raise the learning rate toward 0.03 for faster adaptation, and the threshold to 3.0σ to catch only genuine anomalies amid normal volatility. For more sensitivity, set the bottleneck to 1 (a tighter normal manifold) and the threshold to 2.0σ.
Per parameter: Bottleneck (k) sets sensitivity — smaller defines "normal" more tightly and is more sensitive to deviation. Learning rate sets adaptation speed (higher is nimbler but too high destabilizes). Standardization length sets the feature baseline. Error window sets the anomaly-score baseline (shorter is more locally adaptive). Threshold (σ) sets pulse sensitivity.
💡 How to Use in Practice
The core read is anomaly score × lead feature. While the score stays calm (NORMAL), the market is within its learned normal structure — existing logic tends to work. The moment the score spikes above the threshold (pulse fires) signals structure has temporarily broken — the start of a breakout, a liquidity shock, a flash move, or a news reaction. The lead feature tells you what is anomalous (e.g., a spike with no volume shows up as Body/Range), helping characterize it. The EXTREME level marks especially strong dislocations — a cue for risk management (revisit stops, cut size).
For multi-timeframe work, read higher-timeframe anomalies for major structure breaks and time execution on a lower timeframe. Because it shows when structure breaks (not direction), pair it with trend or directional signals (e.g., avoid trend-following during anomalies).
⚠️ Important Notes
Nothing displays until the warmup period (default 150 bars) completes. Reloading the indicator retrains the weights from scratch — learning state is not persisted. This is a linear autoencoder and does not fully capture nonlinear normal structure (reconstruction error measures deviation from a linear manifold). If an anomaly persists, it is by design learned as the new "normal" (adaptation to non-stationarity). The Mahalanobis distance is a simplified version assuming diagonal covariance (Euclidean in standardized space). The anomaly score shows no direction, only structural breakage. Judging precedes learning, and updates occur on confirmed bars only.
🚨 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.
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.