OPEN-SOURCE SCRIPT
AetherEdge - Mean-Reversion Bands

🖊️ Overview
Ordinary bands flag the stretch but say nothing about what happens next. AE-MRB learns the probability that price reverts to the mean at a band touch and only fades when the odds support it. A UCB-style threshold adapts per trend regime — aggressive in chop, cautious in a trend — with the mean (band center) as the target.
🔶 Key Features
Learned reversion probability — online P(revert) at each band touch (not every touch reverts)
Triple-barrier training — learns from the real outcome: revert / extend (trend) / timeout
Regime-adaptive threshold — UCB tunes the firing probability per ranging/normal/trending regime
Fade signals — long at the lower band, short at the upper band, targeting the mean
σ stretch readout and regime-colored bands
Alerts on high-probability touches; bar-close training and signals — no repaint
🧠 Technical Architecture
Bands: basis (EMA/SMA) ± kBand·standard deviation; stretch = (close − basis)/σ (z-score).
ML (online logistic): at a band touch (a fresh |stretch| ≥ threshold cross), seven fade-oriented features (stretch, trend strength, RSI extremity, band-width regime, volume, mean slope, exhaustion) predict P(reverts to the mean within N bars). Labels are triple-barrier — revert (returns to mean) = 1, extend (stretches further = trend/breakout) = 0, timeout judged by how far it pulled back. Resolved over an array<Setup> with SL priority.
RL (UCB-style adaptive threshold): per trend regime (trend-strength terciles), a UCB tunes the firing probability threshold; reward is tied to the same reversion outcome (one learning loop). Stronger trends demand higher conviction.
Honest scope: a linear classifier + a bandit over standard features. Not deep learning, not a guarantee.
⚙️ Recommended Settings & Tuning Guide (crypto 15m–4H)
Key parameters: basis length, band width σ, touch threshold σ, barrier horizon N, revert/extend levels, learning rate, UCB exploration, min reversion probability.
Touch threshold σ ≈ 1.5–2.0 (lower = more frequent, higher = more selective)
N is the max bars to wait for reversion; 8–15 for 15m–1H
Revert level / extend distance define what counts as success vs failure
Min reversion probability is a floor that suppresses weak-market misfires
Best on range-prone symbols/sessions; in strong trends the UCB automatically throttles firing
💡 How to Use in Practice
Use the fade triangles for counter-trend entries and the mean as the take-profit target
Watch P(revert) vs threshold and take only setups that clear it
When the regime reads TRENDING, fade lightly (pair with a trend tool)
Use the realized revert rate to gauge how reversion-friendly the market is now
Combine with AE-VOL (range envelope) or AE-CORR (drivers) to layer reversion × level
⚠️ Important Notes
Needs a learning period (warmup); learning resets on parameter/timeframe change
Mean reversion fails in strong trends (extend = loss; manage via threshold and regime)
The target mean moves (its level shifts before price reaches it)
Probability, not a guarantee — always do your own due diligence and use risk management
🚨 Disclaimer
This indicator is for educational and informational purposes only and is not financial advice or a recommendation to buy or sell. No method guarantees future profits; past performance does not indicate future results, and trading carries the risk of loss. All decisions are your own — use proper validation and disciplined risk management.
Ordinary bands flag the stretch but say nothing about what happens next. AE-MRB learns the probability that price reverts to the mean at a band touch and only fades when the odds support it. A UCB-style threshold adapts per trend regime — aggressive in chop, cautious in a trend — with the mean (band center) as the target.
🔶 Key Features
Learned reversion probability — online P(revert) at each band touch (not every touch reverts)
Triple-barrier training — learns from the real outcome: revert / extend (trend) / timeout
Regime-adaptive threshold — UCB tunes the firing probability per ranging/normal/trending regime
Fade signals — long at the lower band, short at the upper band, targeting the mean
σ stretch readout and regime-colored bands
Alerts on high-probability touches; bar-close training and signals — no repaint
🧠 Technical Architecture
Bands: basis (EMA/SMA) ± kBand·standard deviation; stretch = (close − basis)/σ (z-score).
ML (online logistic): at a band touch (a fresh |stretch| ≥ threshold cross), seven fade-oriented features (stretch, trend strength, RSI extremity, band-width regime, volume, mean slope, exhaustion) predict P(reverts to the mean within N bars). Labels are triple-barrier — revert (returns to mean) = 1, extend (stretches further = trend/breakout) = 0, timeout judged by how far it pulled back. Resolved over an array<Setup> with SL priority.
RL (UCB-style adaptive threshold): per trend regime (trend-strength terciles), a UCB tunes the firing probability threshold; reward is tied to the same reversion outcome (one learning loop). Stronger trends demand higher conviction.
Honest scope: a linear classifier + a bandit over standard features. Not deep learning, not a guarantee.
⚙️ Recommended Settings & Tuning Guide (crypto 15m–4H)
Key parameters: basis length, band width σ, touch threshold σ, barrier horizon N, revert/extend levels, learning rate, UCB exploration, min reversion probability.
Touch threshold σ ≈ 1.5–2.0 (lower = more frequent, higher = more selective)
N is the max bars to wait for reversion; 8–15 for 15m–1H
Revert level / extend distance define what counts as success vs failure
Min reversion probability is a floor that suppresses weak-market misfires
Best on range-prone symbols/sessions; in strong trends the UCB automatically throttles firing
💡 How to Use in Practice
Use the fade triangles for counter-trend entries and the mean as the take-profit target
Watch P(revert) vs threshold and take only setups that clear it
When the regime reads TRENDING, fade lightly (pair with a trend tool)
Use the realized revert rate to gauge how reversion-friendly the market is now
Combine with AE-VOL (range envelope) or AE-CORR (drivers) to layer reversion × level
⚠️ Important Notes
Needs a learning period (warmup); learning resets on parameter/timeframe change
Mean reversion fails in strong trends (extend = loss; manage via threshold and regime)
The target mean moves (its level shifts before price reaches it)
Probability, not a guarantee — always do your own due diligence and use risk management
🚨 Disclaimer
This indicator is for educational and informational purposes only and is not financial advice or a recommendation to buy or sell. No method guarantees future profits; past performance does not indicate future results, and trading carries the risk of loss. All decisions are your own — use proper validation and disciplined risk management.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。