OPEN-SOURCE SCRIPT

AetherEdge - RainbowDQN Multi-Component

276
🖊️ Overview

A self-evolving multi-component agent that fuses the core pillars of Rainbow DQN into one policy: Double (overestimation control), Dueling (separating state value from action advantage), and Prioritized Replay (re-learning in proportion to surprise / TD error). It learns from a composite reward — risk-adjusted return, drawdown avoidance, and volatility scaling — so it generalizes across trending, ranging, and high-volatility regimes alike. The internals are multi-headed, but their complex valuation is distilled into a single refined unified-signal arrow, rendered with layered glow and a premium intelligence panel.

🔶 Key Features

Three Rainbow components fused — Double + Dueling + Prioritized Replay in one policy
Composite-reward learning — risk-adjusted return + drawdown avoidance + volatility scaling, weighted
Multi-regime adaptability — volatility scaling and drawdown penalty generalize across trend / range / high-vol
Overestimation control (Double) — online net selects, target net evaluates
V/A separation (Dueling) — state value V(s) and advantage A(s,a) on separate streams
Prioritized replay + importance sampling — high-TD-error transitions learned first, with IS bias correction
Unified signal arrow only — multi-head internals distilled into one clean arrow (Layered Glow / Minimal / Labeled styles)
Refined visuals — multi-layer glow arrows, conviction ribbon, signal pulse, and a sectioned premium panel

🧠 Technical Architecture

The agent perceives the market as a five-dimensional state vector: momentum spread, RSI deviation, ADX trend strength, a volatility-regime ratio, and position-within-range — all z-normalized. Two networks exist (online + target), each with a Dueling structure — a shared trunk (tanh) forks into a Value stream V(s) and an Advantage stream A(s,a), recombined as Q = V + (A − mean A).
As Double-DQN, next-state action selection uses the online net's argmax while its valuation uses the target net, curbing overestimation; weights hard-sync every Target Net Sync bars. The composite reward fuses three heads: (1) risk-adjusted return (forward return normalized by ATR), (2) drawdown avoidance (penalizing adverse excursion within the lookahead window), and (3) volatility scaling (shrinking rewards earned under abnormally high volatility).
For prioritized replay, each transition's TD error δ = pred − target is turned into a priority |δ|^α, skewing sampling toward surprising experiences, while an importance-sampling (β) weight corrects the resulting bias. Gradients flow through the dueling aggregation (dQ/dV = 1, dQ/dA = 𝟙[a] − 1/3) into each stream and the shared trunk via manual backpropagation. Finally, a unified conviction blending Q-spread and advantage-spread is computed, and a single arrow is drawn only when it clears the gate.

⚙️ Recommended Settings & Tuning Guide

BTC (1H–4H): Training Horizon 800–1500, γ 0.94, Target Net Sync 25, reward weights Ret 1.0 / DD 0.6 / Vol 0.4. The balanced defaults fit well
ETH (1H–4H): As BTC, with Reward Lookahead 5–8 to value trend persistence
SOL (15m–1H): High volatility favors Vol weight 0.6–0.8 to strengthen scaling, Conviction Gate 0.45–0.55 to be selective
XRP (1H–4H): Spike-prone; DD weight ≈ 0.8 to penalize adverse excursion harder, Priority Exponent ≈ 2.0
Composite weights: raise Ret for trend-seeking, DD for steadier operation, Vol for choppy markets — allocate by market character and style
Conviction Gate: higher (0.5–0.6) gives fewer, higher-quality arrows; lower (0.3–0.4) gives more — tune to your trade frequency
Target Net Sync (τ): short (10–15) adapts fast but less stable; long (40–60) is stable — match to market stability

💡 How to Use in Practice

Reacting to the unified arrow: every arrow shown is the "final verdict" — past the multi-head valuation, composite reward, and conviction gate — a high-confidence core basis for trend-following entries
Using the conviction ribbon: the more saturated the under-price ribbon, the stronger the directional conviction; arrow plus matching ribbon color (teal bullish, coral bearish) is the most coherent setup
Across regimes: follow arrows directly in trends; in ranges the drawdown-avoidance head reduces forced signals; in high-vol the volatility head tempers overreaction
Signal pulse: the pulse dot on the firing bar improves entry-timing visibility
Multi-timeframe usage: confirm the big-picture unified direction on the higher timeframe (4H), then refine timing on aligned arrows on the lower one (15m–1H)
Combinations: pair with volume or key S/R, filtering for high-conviction arrows to lift precision further

⚠️ Important Notes

Initial learning period: right after launch the replay buffer is nearly empty and both networks 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 and the buffer, restarting learning from zero
Target-sync effect: calls may briefly shift right after a sync — this is normal Double-DQN behavior
On forward-looking reward: rewards and drawdown use closed-bar forward data (a standard RL training construct); current-bar evaluation 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

🚨 Disclaimer

This indicator is an analytical and educational visualization tool. The Rainbow DQN (Double/Dueling/Prioritized Replay), composite reward, networks, and signal outputs 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.

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.