OPEN-SOURCE SCRIPT
AetherEdge Self-Evolving S/R Grid

🖊️ Overview
AetherEdge Self-Evolving S/R Grid is a revolutionary self-evolving support & resistance system that brings the philosophy of Q-learning into technical analysis. It learns from market reactions—rejections, breaks, and flips—as "rewards," automatically pruning low-value lines and constructing a Darwinian S/R grid where only functional levels survive. Moving beyond static line-drawing tools, it delivers a truly intelligent price-structure map that breathes and evolves alongside the market itself.
🔶 Key Features
Q-Learning-Style Score Updates: Reinforcement learning replicated through α (learning rate), γ (discount factor), and ε (exploration rate)
Self-Evolving Line Lifecycle: Fully automated birth → learning → reinforcement/pruning cycle
Multi-Source Grid Generation: Pivots / Williams Fractals / Round Numbers / Swing Extremes
Dynamic Reward System: Reject reward, break penalty, S/R flip bonus
ATR-Based Sensitivity: Market-adaptive touch tolerance and break confirmation
Volume-Weighted Reaction Detection: Filters out thin-volume false signals
Score-Based Visualization: Dynamic color, width, and transparency by line strength
Strong Zone Highlighting: Threshold-exceeding lines visually emphasized
Dying Line Display: Pre-pruning lines fade visibly
Comprehensive Stats Panel: Cumulative tracking of generations, deletions, rejects, breaks, flips
Safe Coordinate System: MAX_BARS_BACK clamping to prevent drawing errors on legacy bars
🧠 Technical Architecture
This indicator is an advanced system that reconstructs core reinforcement-learning concepts in Pine Script.
Q-Learning Update Equation: Applies newQ = Q + α × (R + γ × maxFutureQ − Q) to every active line each bar. Each line carries its own "value (Q-value)" and self-updates through market experience.
Reward Function: Price-line interactions are classified into three categories—rejection (+rejectReward), break (−breakPenalty), and S/R flip (+flipReward). Rewards are amplified when volume exceeds the moving average.
Exploration vs. Exploitation Dilemma: explorationRate governs new-line generation frequency. High ε aggressively probes uncharted price zones; low ε prioritizes exploitation of high-Q-value lines.
Grid Generation Strategy: Candidate prices extracted from four sources, deduplicated via existsNear(), validated against psychological levels via isRoundNumber(), and rendered safely using safeX1().
Line Lifecycle: bornBar → lastTouchBar → touches/rejects/breaks/flips accumulation → score update → if below minScore, active=false → automatic deletion.
Score Decay Mechanism: Unreacted lines decay by decayPerBar each bar, naturally pruning non-functional lines through a self-cleansing mechanism.
S/R Flip Detection: After a break, line type inverts; the pendingFlip flag monitors retests, and a flip reward is granted upon successful confirmation.
Visualization Layer: Dynamic line widths (>0.7=3px / >0.5=2px / else=1px) and transparency (80−score×60) by score.
Stats Panel: Five metrics cumulatively tracked via the stats array, with globalSuccessRate aggregating system-wide performance.
⚙️ Recommended Settings & Tuning Guide
Crypto Defaults:
BTC (4H): learningRate=0.15, gridSpacingATR=1.5, maxLines=40, pivotStrength=10
ETH (1H): learningRate=0.20, gridSpacingATR=1.2, maxLines=50, genFrequency=15
SOL/XRP (15M): learningRate=0.25, gridSpacingATR=1.0, maxLines=60, decayPerBar=0.002
Long-Term (1D): learningRate=0.10, gridSpacingATR=2.5, maxLines=30, minScore=0.30
Tuning Guide:
Conservative Learning: α=0.05, γ=0.95 for slow, steady evolution—ideal for long-term trends
Aggressive Learning: α=0.30, ε=0.40 for rapid adaptation—ideal for high-volatility markets
Strict Pruning: minScore=0.35, decayPerBar=0.003 to keep only functional lines
Lenient Pruning: minScore=0.10, decayPerBar=0.0005 to retain more lines
High-Density Grid: gridSpacingATR=0.8, maxLines=80 for scalping
Sparse Grid: gridSpacingATR=3.0, maxLines=20 for long-term swing trading
Volume-Focused: Enable volumeBoost to reward only genuine reactions
Flip Hunting: flipReward=1.0 to emphasize structural reversals
💡 How to Use in Practice
Strong Lines (Yellow Highlight): colStrong lines represent high-Q-value proven levels—enter on confirmed rejection
S/R Flip Tracking: Post-break retest from the opposite side confirms a flip—powerful trend continuation signal
Breakout Strategy: Close beyond breakConfirm × ATR confirms the break—use as the origin of a new trend
Reverse Use of Dying Lines: colDying lines have lost relevance—useful as a filter to ignore stale levels
Multi-Timeframe Integration: Use higher-TF strong lines as anchor entries on lower TFs
AetherEdge Synergy: Combine with Pattern Recognition Trendline for pattern × S/R grid double confirmation
Round-Number Strategy: High-Q lines born from round numbers reflect psychological/institutional support
Grid Trading: High-density settings enable mechanical execution in ranging markets
⚠️ Important Notes
Initial Learning Period: At least 200–500 bars of data accumulation is required before signal quality stabilizes
Learning Reset: Settings changes or chart reloads reset all Q-values, requiring relearning
The ε Trap: Excessive exploration breeds low-quality lines; insufficient exploration delays adaptation
MAX_BARS_BACK Constraint: bornBar values older than 4500 bars are automatically clamped
maxLines Cap: When exceeded, oldest/lowest-score lines are auto-pruned
Regime Changes: During abrupt market shifts, legacy lines may temporarily lose validity until decay resolves them
🚨 Disclaimer
This indicator is a technical analysis tool provided for educational and research purposes only and does not constitute financial advice. Q-learning-style scores are evaluations based on historical price reactions and do not guarantee future performance. All trading decisions are made at your own risk and should be accompanied by proper risk management.
AetherEdge Self-Evolving S/R Grid is a revolutionary self-evolving support & resistance system that brings the philosophy of Q-learning into technical analysis. It learns from market reactions—rejections, breaks, and flips—as "rewards," automatically pruning low-value lines and constructing a Darwinian S/R grid where only functional levels survive. Moving beyond static line-drawing tools, it delivers a truly intelligent price-structure map that breathes and evolves alongside the market itself.
🔶 Key Features
Q-Learning-Style Score Updates: Reinforcement learning replicated through α (learning rate), γ (discount factor), and ε (exploration rate)
Self-Evolving Line Lifecycle: Fully automated birth → learning → reinforcement/pruning cycle
Multi-Source Grid Generation: Pivots / Williams Fractals / Round Numbers / Swing Extremes
Dynamic Reward System: Reject reward, break penalty, S/R flip bonus
ATR-Based Sensitivity: Market-adaptive touch tolerance and break confirmation
Volume-Weighted Reaction Detection: Filters out thin-volume false signals
Score-Based Visualization: Dynamic color, width, and transparency by line strength
Strong Zone Highlighting: Threshold-exceeding lines visually emphasized
Dying Line Display: Pre-pruning lines fade visibly
Comprehensive Stats Panel: Cumulative tracking of generations, deletions, rejects, breaks, flips
Safe Coordinate System: MAX_BARS_BACK clamping to prevent drawing errors on legacy bars
🧠 Technical Architecture
This indicator is an advanced system that reconstructs core reinforcement-learning concepts in Pine Script.
Q-Learning Update Equation: Applies newQ = Q + α × (R + γ × maxFutureQ − Q) to every active line each bar. Each line carries its own "value (Q-value)" and self-updates through market experience.
Reward Function: Price-line interactions are classified into three categories—rejection (+rejectReward), break (−breakPenalty), and S/R flip (+flipReward). Rewards are amplified when volume exceeds the moving average.
Exploration vs. Exploitation Dilemma: explorationRate governs new-line generation frequency. High ε aggressively probes uncharted price zones; low ε prioritizes exploitation of high-Q-value lines.
Grid Generation Strategy: Candidate prices extracted from four sources, deduplicated via existsNear(), validated against psychological levels via isRoundNumber(), and rendered safely using safeX1().
Line Lifecycle: bornBar → lastTouchBar → touches/rejects/breaks/flips accumulation → score update → if below minScore, active=false → automatic deletion.
Score Decay Mechanism: Unreacted lines decay by decayPerBar each bar, naturally pruning non-functional lines through a self-cleansing mechanism.
S/R Flip Detection: After a break, line type inverts; the pendingFlip flag monitors retests, and a flip reward is granted upon successful confirmation.
Visualization Layer: Dynamic line widths (>0.7=3px / >0.5=2px / else=1px) and transparency (80−score×60) by score.
Stats Panel: Five metrics cumulatively tracked via the stats array, with globalSuccessRate aggregating system-wide performance.
⚙️ Recommended Settings & Tuning Guide
Crypto Defaults:
BTC (4H): learningRate=0.15, gridSpacingATR=1.5, maxLines=40, pivotStrength=10
ETH (1H): learningRate=0.20, gridSpacingATR=1.2, maxLines=50, genFrequency=15
SOL/XRP (15M): learningRate=0.25, gridSpacingATR=1.0, maxLines=60, decayPerBar=0.002
Long-Term (1D): learningRate=0.10, gridSpacingATR=2.5, maxLines=30, minScore=0.30
Tuning Guide:
Conservative Learning: α=0.05, γ=0.95 for slow, steady evolution—ideal for long-term trends
Aggressive Learning: α=0.30, ε=0.40 for rapid adaptation—ideal for high-volatility markets
Strict Pruning: minScore=0.35, decayPerBar=0.003 to keep only functional lines
Lenient Pruning: minScore=0.10, decayPerBar=0.0005 to retain more lines
High-Density Grid: gridSpacingATR=0.8, maxLines=80 for scalping
Sparse Grid: gridSpacingATR=3.0, maxLines=20 for long-term swing trading
Volume-Focused: Enable volumeBoost to reward only genuine reactions
Flip Hunting: flipReward=1.0 to emphasize structural reversals
💡 How to Use in Practice
Strong Lines (Yellow Highlight): colStrong lines represent high-Q-value proven levels—enter on confirmed rejection
S/R Flip Tracking: Post-break retest from the opposite side confirms a flip—powerful trend continuation signal
Breakout Strategy: Close beyond breakConfirm × ATR confirms the break—use as the origin of a new trend
Reverse Use of Dying Lines: colDying lines have lost relevance—useful as a filter to ignore stale levels
Multi-Timeframe Integration: Use higher-TF strong lines as anchor entries on lower TFs
AetherEdge Synergy: Combine with Pattern Recognition Trendline for pattern × S/R grid double confirmation
Round-Number Strategy: High-Q lines born from round numbers reflect psychological/institutional support
Grid Trading: High-density settings enable mechanical execution in ranging markets
⚠️ Important Notes
Initial Learning Period: At least 200–500 bars of data accumulation is required before signal quality stabilizes
Learning Reset: Settings changes or chart reloads reset all Q-values, requiring relearning
The ε Trap: Excessive exploration breeds low-quality lines; insufficient exploration delays adaptation
MAX_BARS_BACK Constraint: bornBar values older than 4500 bars are automatically clamped
maxLines Cap: When exceeded, oldest/lowest-score lines are auto-pruned
Regime Changes: During abrupt market shifts, legacy lines may temporarily lose validity until decay resolves them
🚨 Disclaimer
This indicator is a technical analysis tool provided for educational and research purposes only and does not constitute financial advice. Q-learning-style scores are evaluations based on historical price reactions and do not guarantee future performance. All trading decisions are made at your own risk and should be accompanied by proper 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.