OPEN-SOURCE SCRIPT
AetherEdge - Bayesian Neural Market Microstructure

🖊️ Overview
A NeuraLib Bayesian Neural Network that does what a point-estimate model (e.g. a plain LSTM) cannot: it predicts WITH a confidence. Instead of one number, it runs many stochastic forward passes (MC-Dropout / weight-perturbation style) to produce a DISTRIBUTION of next-move predictions, reporting both a mean forecast and an uncertainty (the spread of the samples). Inputs are market-microstructure proxies — volume delta (buy/sell pressure), an estimated spread, and a liquidity proxy — alongside price features. Visualization: a probability-density "cloud" of predicted price bands (opacity ∝ probability) and a single forward zone that reddens as uncertainty rises. The edge over LSTM-style tools is clear — you see not just where, but how sure.
🔶 Key Features
Bayesian NN (uncertainty estimation) — multi-sample weight perturbation yields a predictive distribution: mean + uncertainty
Confidence-aware prediction — "mean ± σ", not a point estimate — the decisive difference from LSTM-style tools
Microstructure inputs — volume delta (order-flow proxy), estimated spread, and a liquidity proxy as features
Probability-density cloud — predicted bands drawn as nested probability tiers, opacity encoding probability mass (denser inside)
Uncertainty zone — a single forward zone that reddens and gains opacity as uncertainty rises
Mean forecast line — one line from current price to predicted price (with glow)
Online learning — the network continuously regresses toward realized forward moves
Intelligence panel — predicted move, predicted price, confidence, uncertainty, and each microstructure component at a glance
🧠 Technical Architecture
The agent perceives the market as a four-dimensional microstructure state: price momentum, order-flow pressure (a normalized volume delta from candle-direction × volume EMA), spread regime (an estimated effective spread from the high-low range), and liquidity (volume per unit range) — all z-normalized.
The network is in(4) → hidden(tanh) → out(1) = predicted normalized move, but its Bayesian behavior is reproduced via stochastic forward passes. Each sample (1) injects Gaussian-style noise into the weights (variational weight perturbation) and (2) applies an MC-Dropout mask to hidden units. Repeating this MC Samples times, the mean of the predictions is the forecast and their standard deviation is the uncertainty (epistemic uncertainty) — the heart of the Bayesian approximation.
Learning is supervised regression: for each state, the realized normalized move (close − close[h]) / ATR over the prediction horizon is the target, and the mean network regresses toward it via squared error (sampled from a replay buffer). For visualization, around the predicted price close + mean·ATR, nested probability bands of half-width k·σ·ATR form the density cloud, with opacity proportional to Gaussian mass exp(−0.5k²). The uncertainty zone gradients from the forecast color to red, with a bold red border once normalized uncertainty crosses the threshold.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): MC Samples 12, Dropout 0.25, Weight Noise 0.05, Prediction Horizon 8, Cloud Bands 5. Standard settings fit well
ETH (1H–4H): As BTC, with Uncertainty Scale 1.0 for standard cloud width
SOL (15m–1H): High volatility favors Dropout 0.3 / Weight Noise 0.08 for more sensitive uncertainty, Red Zone Threshold 0.5 to warn risk early
XRP (1H–4H): Spike-prone; MC Samples ≈ 16 to smooth the distribution, Uncertainty Scale 1.2 for slightly wider clouds
MC Samples: more smooths the uncertainty estimate but is heavier; 10–16 is a practical balance
Dropout / Weight Noise: higher widens the predictive distribution and raises uncertainty — tune to market noise
Cloud Density Bands: more makes a smoother, prettier cloud but adds render load; 4–6 is readable
Red Zone Threshold: lower warns red earlier (conservative); higher keeps the cool color only when very confident
💡 How to Use in Practice
Reading the density cloud: a narrow, dense cloud = low uncertainty, high-confidence forecast; a wide, faint cloud = high uncertainty, unstable forecast. The cloud center (mean line) is the predicted price
Uncertainty zone color: a forecast-colored (teal/coral) zone means confidence; a red, bold-bordered zone means high uncertainty — enter cautiously
Using confidence-aware prediction: consider entries only when panel Confidence is high — unlike point predictors (LSTM etc.), you can judge whether to trust the forecast
Checking microstructure: when order-flow Δ, spread, and liquidity align with the forecast direction, the prediction is better supported
Cloud width and sizing: size larger when the cloud is narrow (low uncertainty), smaller when wide (high uncertainty)
Multi-timeframe usage: confirm the big-picture forecast direction and uncertainty on the higher timeframe (4H), then time entries in low-uncertainty windows on the lower one (15m–1H)
⚠️ Important Notes
Initial learning period: right after launch the buffer is nearly empty and the network is untrained, so forecasts are unstable; treat them as low-confidence until it fills (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes the network weights and buffer, restarting learning from zero
On microstructure proxies: this uses microstructure proxies estimated from OHLCV, not a real order book — an approximation that differs from true book data
Interpreting uncertainty: the reported uncertainty is the model's epistemic uncertainty (its lack of confidence), not a complete measure of actual market risk
On look-ahead: the target uses closed-bar realized moves (a standard training construct); current-bar prediction is on confirmed values, but as with any adaptive system, historical and live behavior can differ — always forward-test
Constraints: this is a lightweight implementation operating within Pine's compute budget; raising MC Samples increases compute proportionally
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The Bayesian neural network, uncertainty estimation, microstructure proxies, predictive distribution, and density cloud are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Even a probabilistic forecast can be wrong. Always combine any tool with your own analysis and disciplined risk management.
A NeuraLib Bayesian Neural Network that does what a point-estimate model (e.g. a plain LSTM) cannot: it predicts WITH a confidence. Instead of one number, it runs many stochastic forward passes (MC-Dropout / weight-perturbation style) to produce a DISTRIBUTION of next-move predictions, reporting both a mean forecast and an uncertainty (the spread of the samples). Inputs are market-microstructure proxies — volume delta (buy/sell pressure), an estimated spread, and a liquidity proxy — alongside price features. Visualization: a probability-density "cloud" of predicted price bands (opacity ∝ probability) and a single forward zone that reddens as uncertainty rises. The edge over LSTM-style tools is clear — you see not just where, but how sure.
🔶 Key Features
Bayesian NN (uncertainty estimation) — multi-sample weight perturbation yields a predictive distribution: mean + uncertainty
Confidence-aware prediction — "mean ± σ", not a point estimate — the decisive difference from LSTM-style tools
Microstructure inputs — volume delta (order-flow proxy), estimated spread, and a liquidity proxy as features
Probability-density cloud — predicted bands drawn as nested probability tiers, opacity encoding probability mass (denser inside)
Uncertainty zone — a single forward zone that reddens and gains opacity as uncertainty rises
Mean forecast line — one line from current price to predicted price (with glow)
Online learning — the network continuously regresses toward realized forward moves
Intelligence panel — predicted move, predicted price, confidence, uncertainty, and each microstructure component at a glance
🧠 Technical Architecture
The agent perceives the market as a four-dimensional microstructure state: price momentum, order-flow pressure (a normalized volume delta from candle-direction × volume EMA), spread regime (an estimated effective spread from the high-low range), and liquidity (volume per unit range) — all z-normalized.
The network is in(4) → hidden(tanh) → out(1) = predicted normalized move, but its Bayesian behavior is reproduced via stochastic forward passes. Each sample (1) injects Gaussian-style noise into the weights (variational weight perturbation) and (2) applies an MC-Dropout mask to hidden units. Repeating this MC Samples times, the mean of the predictions is the forecast and their standard deviation is the uncertainty (epistemic uncertainty) — the heart of the Bayesian approximation.
Learning is supervised regression: for each state, the realized normalized move (close − close[h]) / ATR over the prediction horizon is the target, and the mean network regresses toward it via squared error (sampled from a replay buffer). For visualization, around the predicted price close + mean·ATR, nested probability bands of half-width k·σ·ATR form the density cloud, with opacity proportional to Gaussian mass exp(−0.5k²). The uncertainty zone gradients from the forecast color to red, with a bold red border once normalized uncertainty crosses the threshold.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): MC Samples 12, Dropout 0.25, Weight Noise 0.05, Prediction Horizon 8, Cloud Bands 5. Standard settings fit well
ETH (1H–4H): As BTC, with Uncertainty Scale 1.0 for standard cloud width
SOL (15m–1H): High volatility favors Dropout 0.3 / Weight Noise 0.08 for more sensitive uncertainty, Red Zone Threshold 0.5 to warn risk early
XRP (1H–4H): Spike-prone; MC Samples ≈ 16 to smooth the distribution, Uncertainty Scale 1.2 for slightly wider clouds
MC Samples: more smooths the uncertainty estimate but is heavier; 10–16 is a practical balance
Dropout / Weight Noise: higher widens the predictive distribution and raises uncertainty — tune to market noise
Cloud Density Bands: more makes a smoother, prettier cloud but adds render load; 4–6 is readable
Red Zone Threshold: lower warns red earlier (conservative); higher keeps the cool color only when very confident
💡 How to Use in Practice
Reading the density cloud: a narrow, dense cloud = low uncertainty, high-confidence forecast; a wide, faint cloud = high uncertainty, unstable forecast. The cloud center (mean line) is the predicted price
Uncertainty zone color: a forecast-colored (teal/coral) zone means confidence; a red, bold-bordered zone means high uncertainty — enter cautiously
Using confidence-aware prediction: consider entries only when panel Confidence is high — unlike point predictors (LSTM etc.), you can judge whether to trust the forecast
Checking microstructure: when order-flow Δ, spread, and liquidity align with the forecast direction, the prediction is better supported
Cloud width and sizing: size larger when the cloud is narrow (low uncertainty), smaller when wide (high uncertainty)
Multi-timeframe usage: confirm the big-picture forecast direction and uncertainty on the higher timeframe (4H), then time entries in low-uncertainty windows on the lower one (15m–1H)
⚠️ Important Notes
Initial learning period: right after launch the buffer is nearly empty and the network is untrained, so forecasts are unstable; treat them as low-confidence until it fills (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes the network weights and buffer, restarting learning from zero
On microstructure proxies: this uses microstructure proxies estimated from OHLCV, not a real order book — an approximation that differs from true book data
Interpreting uncertainty: the reported uncertainty is the model's epistemic uncertainty (its lack of confidence), not a complete measure of actual market risk
On look-ahead: the target uses closed-bar realized moves (a standard training construct); current-bar prediction is on confirmed values, but as with any adaptive system, historical and live behavior can differ — always forward-test
Constraints: this is a lightweight implementation operating within Pine's compute budget; raising MC Samples increases compute proportionally
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The Bayesian neural network, uncertainty estimation, microstructure proxies, predictive distribution, and density cloud are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Even a probabilistic forecast can be wrong. Always combine any tool with your own analysis and disciplined risk management.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.