OPEN-SOURCE SCRIPT

AetherEdge - Adaptive Trend Bandit

4 920
🖊️ Overview

AE-ATB is an adaptive SuperTrend whose ATR multiplier is chosen by a learning bandit. A fixed-multiplier SuperTrend is too tight in calm markets and too loose in volatile ones. AE-ATB first discovers volatility regimes with online k-means, then a contextual bandit (UCB) learns which ATR multiplier has actually paid in each regime. It does not just switch the multiplier with volatility — it learns the best one from reward.

🔶 Key Features

Streaming k-means sorts relative volatility into calm / normal / volatile regimes (not hard-coded thresholds)
A contextual multi-armed bandit (UCB) learns the best ATR multiplier per regime from realized return
A time-varying adaptive SuperTrend that tightens or widens by regime automatically
Direction-colored line and fill, with BUY/SELL signals on trend flips
A gold HUD showing trend, volatility regime, selected multiplier, learned best multiplier, arm value, and pull count
Deterministic exploration (UCB) — identical across reloads, no repaint

🧠 Technical Architecture

k-means (unsupervised): relative volatility = ATR / SMA(ATR) is the feature; three centroids update by competitive learning (only the winning centroid moves, c += lr·(x − c)). Centroid order ranks calm/normal/volatile.
UCB bandit (RL): candidate ATR multipliers (base, base+step, …) are the arms and the volatility cluster is the context. Each (context, arm) value Q is an incremental mean; selection is UCB1: argmax(Q + c·√(ln(total pulls)/pulls)), prioritizing untried arms while balancing exploration and exploitation. Reward = held direction × realized return (ATR units), so multipliers that kept us on the right side of the move score higher.
Adaptive SuperTrend: standard bands = hl2 ± (selected multiplier × ATR), updated each bar with the selected multiplier; direction flips on a break of the active band.
Honest scope: online k-means plus a UCB contextual bandit. SuperTrend is a public concept; this is not a neural network and not a crystal ball.

⚙️ Recommended Settings & Tuning Guide

Key parameters: ATR length, volatility baseline length, multiplier base/step/count, ucbC (exploration), warmup.
Raise ucbC → more exploration (tries more multipliers); lower → more exploitation (sticks to the learned best)
Match the multiplier range (base … base + step×(count−1)) to the instrument's volatility character
Crypto starting points (tune on your chart):
BTC / ETH (1H–4H): defaults are the baseline (base 1.5, step 0.5, 5 arms)
SOL / XRP and high-vol alts: base 2.0 / step 0.5 for a wider range to avoid wick stop-outs
Scalping (5–15m): shorter ATR length, slightly tighter multiplier range
Swing (daily): wider multiplier range, longer warmup so each regime is learned
Right after a new regime appears, behavior is unsettled until each multiplier has been tried once (UCB exploration)

💡 How to Use in Practice

Trend-following: ride the line color and BUY/SELL; a larger multiplier means a roomier trail, a smaller one a tighter trail
Reading the regime: in VOLATILE the multiplier widens to avoid fakeout stop-outs; in CALM it tightens to get on board sooner — automatic adaptation
Best-multiplier panel: shows the learned best multiplier for the current regime, useful as a manual-trail reference
Multi-timeframe: higher-timeframe AE-ATB for the trend, lower for timing
Combinations: pair with AE-QUORUM's directional probability or AE-VECTOR's target band, and let AE-ATB's trail run the winner

⚠️ Important Notes

Learning period: no signals fire until warmup bars; the bandit needs time to learn each regime's multiplier
Learning reset: changing inputs, symbol, or timeframe re-learns the centroids and arm values
Multiplier moves while exploring: early on the multiplier shifts and the adaptive SuperTrend can jump or whipsaw (it settles as pulls accumulate)
Trend-following's nature: in ranges it can suffer repeated stop-outs — use the regime read and position sizing together

🚨 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 trading decisions are your own — use proper backtesting and disciplined risk management.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。