OPEN-SOURCE SCRIPT
AetherEdge - Self-Attention Focus

🖊️ Overview
AE-FOCUS uses the Transformer self-attention mechanism to compute "which past moments does NOW most resemble" and forecasts from the outcomes of those analogous states. Each bar is a feature vector; the current query is dotted against past keys, softmax-normalized into attention weights, and the "what happened after" of high-attention past bars is weight-averaged into a forecast. Glowing arcs sweep from NOW back to resonating past bars, brighter where attention is stronger — a visualization unprecedented in Pine.
🔶 Key Features
Self-attention mechanism: genuine query-key-value-softmax structure
4-D feature vector: standardized return, momentum, RSI-deviation, volatility-ratio
Attention-weighted forecast: weight-averages outcomes of analogous past states
Resonance arc rendering: curves from NOW to high-attention bars visualize resonance
Arc brightness/width scales with attention strength
Online forecast hit-rate tracking
Confidence from attention concentration (entropy-based)
Forecast-direction background + BUY/SELL markers
HUD showing resonance target and concentration
Per-event alerts
🧠 Technical Architecture
This implements the self-attention mechanism. Each bar's feature vector is standardized 4-D [return, momentum, RSI-deviation, volatility-ratio]. With query = current features and key_s = past bar s features, the attention score score(s) = (q · k_s)/√d is computed and normalized α(s) = softmax_s(score/τ) (τ = temperature). value(s) = the realized return in the h bars after bar s (known since s is far enough in the past). forecast = Σ α(s)·value(s) weight-averages the outcomes of analogous states into a predicted return. This is effectively attention-kernel regression over past states similar to the current one. The forecast's hit-rate is tracked online, combined with attention concentration (entropy) and forecast magnitude into confidence. Signals fire when the smoothed forecast crosses threshold.
⚙️ Recommended Settings & Tuning Guide
Attention Lookback (N) 60 is a starting point — the past bars the current query attends over. Outcome Horizon (h) 5 is the value horizon (outcome in the h bars after each past bar) and the forecast horizon. Softmax Temperature (τ) 1.0 is attention sharpness — lower focuses hard on the single closest analog (sharp), higher is more averaged (soft). Feature Normalization Window 100 is the standardization window. Forecast Threshold 0.15 is the firing threshold (normalized return). Arc Threshold 2.5 is how many times the average attention a bar must exceed to get an arc; Arc Height 2.0 is the arc height.
💡 How to Use in Practice
Apply to chart and glowing arcs sweep from NOW to high-attention past bars. The past moments where arcs cluster are those most "resonating" with now. Green arcs mean analogous states rose afterward (bullish forecast); red means they fell (bearish). The HUD's "resonates with" shows how many bars ago resonates most, and "concentration" shows attention concentration (whether a clear analog exists). When concentration is high and forecast hit-rate is high, signal reliability rises. Lowering τ reacts sharply to the single closest analog; raising it gives a smooth forecast averaged over many states.
⚠️ Important Notes
This is single-head attention with fixed (identity/statistical) projections — learned W_Q/W_K/W_V weights and multi-head are outside Pine's limits. It is effectively attention-kernel regression over analogous states, but the query-key-value-softmax structure is the genuine attention mechanism. The forecast is a probabilistic decision based on outcomes of analogous past states, not a certain prediction (past analogies are not guaranteed to repeat). Attention arcs show only the latest bar's resonance and update in real time. All signals are probabilistic decisions based on historical data and do not guarantee future profits.
🚨 Disclaimer
This indicator is provided for educational and informational purposes only and does not constitute financial or investment advice. No signal guarantees future profit, and past performance does not indicate future results. All trading decisions are made at your own risk.
AE-FOCUS uses the Transformer self-attention mechanism to compute "which past moments does NOW most resemble" and forecasts from the outcomes of those analogous states. Each bar is a feature vector; the current query is dotted against past keys, softmax-normalized into attention weights, and the "what happened after" of high-attention past bars is weight-averaged into a forecast. Glowing arcs sweep from NOW back to resonating past bars, brighter where attention is stronger — a visualization unprecedented in Pine.
🔶 Key Features
Self-attention mechanism: genuine query-key-value-softmax structure
4-D feature vector: standardized return, momentum, RSI-deviation, volatility-ratio
Attention-weighted forecast: weight-averages outcomes of analogous past states
Resonance arc rendering: curves from NOW to high-attention bars visualize resonance
Arc brightness/width scales with attention strength
Online forecast hit-rate tracking
Confidence from attention concentration (entropy-based)
Forecast-direction background + BUY/SELL markers
HUD showing resonance target and concentration
Per-event alerts
🧠 Technical Architecture
This implements the self-attention mechanism. Each bar's feature vector is standardized 4-D [return, momentum, RSI-deviation, volatility-ratio]. With query = current features and key_s = past bar s features, the attention score score(s) = (q · k_s)/√d is computed and normalized α(s) = softmax_s(score/τ) (τ = temperature). value(s) = the realized return in the h bars after bar s (known since s is far enough in the past). forecast = Σ α(s)·value(s) weight-averages the outcomes of analogous states into a predicted return. This is effectively attention-kernel regression over past states similar to the current one. The forecast's hit-rate is tracked online, combined with attention concentration (entropy) and forecast magnitude into confidence. Signals fire when the smoothed forecast crosses threshold.
⚙️ Recommended Settings & Tuning Guide
Attention Lookback (N) 60 is a starting point — the past bars the current query attends over. Outcome Horizon (h) 5 is the value horizon (outcome in the h bars after each past bar) and the forecast horizon. Softmax Temperature (τ) 1.0 is attention sharpness — lower focuses hard on the single closest analog (sharp), higher is more averaged (soft). Feature Normalization Window 100 is the standardization window. Forecast Threshold 0.15 is the firing threshold (normalized return). Arc Threshold 2.5 is how many times the average attention a bar must exceed to get an arc; Arc Height 2.0 is the arc height.
💡 How to Use in Practice
Apply to chart and glowing arcs sweep from NOW to high-attention past bars. The past moments where arcs cluster are those most "resonating" with now. Green arcs mean analogous states rose afterward (bullish forecast); red means they fell (bearish). The HUD's "resonates with" shows how many bars ago resonates most, and "concentration" shows attention concentration (whether a clear analog exists). When concentration is high and forecast hit-rate is high, signal reliability rises. Lowering τ reacts sharply to the single closest analog; raising it gives a smooth forecast averaged over many states.
⚠️ Important Notes
This is single-head attention with fixed (identity/statistical) projections — learned W_Q/W_K/W_V weights and multi-head are outside Pine's limits. It is effectively attention-kernel regression over analogous states, but the query-key-value-softmax structure is the genuine attention mechanism. The forecast is a probabilistic decision based on outcomes of analogous past states, not a certain prediction (past analogies are not guaranteed to repeat). Attention arcs show only the latest bar's resonance and update in real time. All signals are probabilistic decisions based on historical data and do not guarantee future profits.
🚨 Disclaimer
This indicator is provided for educational and informational purposes only and does not constitute financial or investment advice. No signal guarantees future profit, and past performance does not indicate future results. All trading decisions are made at your own risk.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.