OPEN-SOURCE SCRIPT
AetherEdge - DuelingDQN Breakout Hunter

🖊️ Overview
A self-evolving breakout agent built on a Dueling Deep-Q-Network that learns to hunt breakouts on its own. Its defining trait is a forked network: a Value stream V(s) that learns "how promising is this state at all", and an Advantage stream A(s,a) that learns "which action is relatively better here", recombined as Q(s,a) = V(s) + (A(s,a) − mean A). This separation lets the agent value the breakout context independently of the directional decision, sharpening action selection exactly where it counts — inside detected breakout zones. Learning from experience on your chart, it visualizes its hunt with auto support/resistance boxes and faint probability arrows.
🔶 Key Features
Dueling DQN architecture — shared trunk → Value and Advantage streams → recombined via the dueling aggregation; state quality and action advantage learned separately
Self-evolving breakout learning — no pre-training; breakout context learned continuously from the live chart
Breakout reward bonus — extra reward for correct actions in breakout context, focusing learning on breakouts
Auto S/R zones — boxes spawn on rolling S/R breaks, with full lifecycle management
Faint probability arrows — drawn with subtle opacity scaled to softmax action probabilities derived from advantages
Prioritized Experience Replay (PER) — high-reward transitions re-learned preferentially
Exploration vs. exploitation — ε-greedy exploration avoids ossifying in local optima
Intelligence panel — V(s), per-action A(s,a), selected action, advantage spread, breakout context, and zone count at a glance
🧠 Technical Architecture
The agent perceives the market as a four-dimensional state vector: momentum spread (ATR-normalized fast/slow EMA gap), relative position within Bollinger Bands, ATR distance to the nearest S/R, and a volatility-regime ratio — all z-normalized.
The core is the Dueling structure. Input passes through a shared trunk (tanh hidden), then forks. The Value stream runs through its hidden layer to a scalar V(s); the Advantage stream runs through its hidden layer to three per-action values A(s,a). They aggregate as Q(s,a) = V(s) + (A(s,a) − mean_a A(s,a)), the mean-subtraction ensuring identifiability between Value and Advantage. Learning is done by manual backpropagation through this aggregation: gradients are correctly distributed to the advantage outputs (dQ/dA = 𝟙[a] − 1/3) and the value output (dQ/dV = 1), then propagated back through each stream's hidden layer and into the shared trunk.
The reward function is a directional, ATR-normalized forward return, plus a bonus for success in breakout context. Transitions (s, a, r, s′) enter the experience replay buffer, sampled by |reward|^exponent. As the zone lifecycle, boxes spawn on rolling S/R breaks and are pruned oldest-first on lifespan or cap overflow. Probability arrows vary in opacity by softmax advantage probability and are drawn only when the advantage spread clears the gate. The statistics panel makes the internal Value and Advantage readable.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): Training Horizon 800–1500, γ 0.92–0.95, Shared Hidden 8 / Stream Hidden 4, S/R Lookback 20, Breakout Bonus 0.5. Standard settings fit well
ETH (1H–4H): As BTC, with Reward Lookahead 5–8 to value post-break follow-through
SOL (15m–1H): High volatility favors Zone Width 0.3–0.5 (wider boxes absorb fakeouts), ε 0.05–0.08, Breakout Bonus 0.6–0.8 to strengthen breakout learning
XRP (1H–4H): Spike-prone; Priority Exponent ≈ 2.0, longer S/R Lookback (25–30) to focus on major levels
Learning Rate α: 0.02–0.04 in trending markets; 0.04–0.08 in choppy ones
Stream Hidden Units: widen to 6–8 for richer advantage representation on instruments with diverse breakout types
maxBoxes / Zone Lifespan: maxBoxes 4–6 to see only key levels; extend Lifespan to retain zones longer
💡 How to Use in Practice
Reacting to high-advantage actions: when one action's advantage dominates with a high spread, the agent sees a clear edge in the break direction — a basis for trend-following entries
Using S/R boxes: auto-spawned zones mark post-break retest (return-move) levels; watch reactions at zone edges
S/R flips: capture the classic pattern where a broken resistance zone flips to support, via the box plus the advantage shift
Arrow opacity: darker arrows mean higher action probability and stronger conviction; treat faint arrows as wait-and-see
Multi-timeframe usage: read the big-picture break and zones on the higher timeframe (4H), then refine timing on aligned high-advantage actions on the lower one (15m–1H)
Combinations: filter for breaks accompanied by volume surges to reject fakeouts and elevate signal quality
⚠️ Important Notes
Initial learning period: right after launch the replay buffer is nearly empty and both Value and Advantage are unstable; treat signals as low-confidence until it fills (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes all network weights, the buffer, and zones, restarting learning from zero
Nature of zones: boxes are structural markers from rolling S/R breaks, not signals in themselves; judge alongside the agent's advantage
On forward-looking reward: rewards use closed-bar forward return (a standard RL training construct); current-bar action selection is made 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
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The Dueling Deep-Q-Network, experience replay, reward shaping, breakout-zone detection, and action probabilities are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Reinforcement-learning agents can and do make wrong calls. Always combine any tool with your own analysis and disciplined risk management.
A self-evolving breakout agent built on a Dueling Deep-Q-Network that learns to hunt breakouts on its own. Its defining trait is a forked network: a Value stream V(s) that learns "how promising is this state at all", and an Advantage stream A(s,a) that learns "which action is relatively better here", recombined as Q(s,a) = V(s) + (A(s,a) − mean A). This separation lets the agent value the breakout context independently of the directional decision, sharpening action selection exactly where it counts — inside detected breakout zones. Learning from experience on your chart, it visualizes its hunt with auto support/resistance boxes and faint probability arrows.
🔶 Key Features
Dueling DQN architecture — shared trunk → Value and Advantage streams → recombined via the dueling aggregation; state quality and action advantage learned separately
Self-evolving breakout learning — no pre-training; breakout context learned continuously from the live chart
Breakout reward bonus — extra reward for correct actions in breakout context, focusing learning on breakouts
Auto S/R zones — boxes spawn on rolling S/R breaks, with full lifecycle management
Faint probability arrows — drawn with subtle opacity scaled to softmax action probabilities derived from advantages
Prioritized Experience Replay (PER) — high-reward transitions re-learned preferentially
Exploration vs. exploitation — ε-greedy exploration avoids ossifying in local optima
Intelligence panel — V(s), per-action A(s,a), selected action, advantage spread, breakout context, and zone count at a glance
🧠 Technical Architecture
The agent perceives the market as a four-dimensional state vector: momentum spread (ATR-normalized fast/slow EMA gap), relative position within Bollinger Bands, ATR distance to the nearest S/R, and a volatility-regime ratio — all z-normalized.
The core is the Dueling structure. Input passes through a shared trunk (tanh hidden), then forks. The Value stream runs through its hidden layer to a scalar V(s); the Advantage stream runs through its hidden layer to three per-action values A(s,a). They aggregate as Q(s,a) = V(s) + (A(s,a) − mean_a A(s,a)), the mean-subtraction ensuring identifiability between Value and Advantage. Learning is done by manual backpropagation through this aggregation: gradients are correctly distributed to the advantage outputs (dQ/dA = 𝟙[a] − 1/3) and the value output (dQ/dV = 1), then propagated back through each stream's hidden layer and into the shared trunk.
The reward function is a directional, ATR-normalized forward return, plus a bonus for success in breakout context. Transitions (s, a, r, s′) enter the experience replay buffer, sampled by |reward|^exponent. As the zone lifecycle, boxes spawn on rolling S/R breaks and are pruned oldest-first on lifespan or cap overflow. Probability arrows vary in opacity by softmax advantage probability and are drawn only when the advantage spread clears the gate. The statistics panel makes the internal Value and Advantage readable.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): Training Horizon 800–1500, γ 0.92–0.95, Shared Hidden 8 / Stream Hidden 4, S/R Lookback 20, Breakout Bonus 0.5. Standard settings fit well
ETH (1H–4H): As BTC, with Reward Lookahead 5–8 to value post-break follow-through
SOL (15m–1H): High volatility favors Zone Width 0.3–0.5 (wider boxes absorb fakeouts), ε 0.05–0.08, Breakout Bonus 0.6–0.8 to strengthen breakout learning
XRP (1H–4H): Spike-prone; Priority Exponent ≈ 2.0, longer S/R Lookback (25–30) to focus on major levels
Learning Rate α: 0.02–0.04 in trending markets; 0.04–0.08 in choppy ones
Stream Hidden Units: widen to 6–8 for richer advantage representation on instruments with diverse breakout types
maxBoxes / Zone Lifespan: maxBoxes 4–6 to see only key levels; extend Lifespan to retain zones longer
💡 How to Use in Practice
Reacting to high-advantage actions: when one action's advantage dominates with a high spread, the agent sees a clear edge in the break direction — a basis for trend-following entries
Using S/R boxes: auto-spawned zones mark post-break retest (return-move) levels; watch reactions at zone edges
S/R flips: capture the classic pattern where a broken resistance zone flips to support, via the box plus the advantage shift
Arrow opacity: darker arrows mean higher action probability and stronger conviction; treat faint arrows as wait-and-see
Multi-timeframe usage: read the big-picture break and zones on the higher timeframe (4H), then refine timing on aligned high-advantage actions on the lower one (15m–1H)
Combinations: filter for breaks accompanied by volume surges to reject fakeouts and elevate signal quality
⚠️ Important Notes
Initial learning period: right after launch the replay buffer is nearly empty and both Value and Advantage are unstable; treat signals as low-confidence until it fills (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes all network weights, the buffer, and zones, restarting learning from zero
Nature of zones: boxes are structural markers from rolling S/R breaks, not signals in themselves; judge alongside the agent's advantage
On forward-looking reward: rewards use closed-bar forward return (a standard RL training construct); current-bar action selection is made 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
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The Dueling Deep-Q-Network, experience replay, reward shaping, breakout-zone detection, and action probabilities are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Reinforcement-learning agents can and do make wrong calls. Always combine any tool with your own analysis and disciplined risk management.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.