OPEN-SOURCE SCRIPT
AetherEdge - Bayesian Changepoint Shift

🖊️ Overview
AE-SHIFT detects trend reversals as a probability using Bayesian Online Changepoint Detection (BOCPD, Adams & MacKay 2007). Rather than "did a moving average cross?", it asks "what is the probability that the current price regime just ended?" — computing a full posterior distribution over how long the current trend has lasted (run-length). An adaptive layer learns the hazard (reversal frequency) online from the spacing between changepoints, auto-adapting to each instrument's rhythm.
🔶 Key Features
Faithful BOCPD: sequential Bayesian update of the run-length posterior
Gaussian predictive likelihood + Welford online statistics: probabilistic evaluation of each regime hypothesis
Adaptive hazard learning: auto-estimates expected run-length λ from changepoint intervals
Quantifies changepoint probability 0-100%: clear reversal signal
Multi-layer glow rendering: luminous vertical lines at changepoints
Run-length distribution mini-heatmap: visualizes the distribution shape in the HUD
Probability-linked background pulse and segment trend line
BUY/SELL markers + per-event alerts
🧠 Technical Architecture
This implements the core BOCPD algorithm. Each bar maintains P(run-length = r | data) for r = 0..Rmax, with each hypothesis carrying Welford online statistics (mean/variance) of returns inside the segment. For each new observation, a Gaussian predictive likelihood π(x|r) is computed, weighted by the hazard function H = 1/λ, propagated forward (growth: r→r+1), with changepoint mass collapsed to r=0 and normalized. P(r=0) is the changepoint probability. Observations are ATR-normalized returns for scale stability. Adaptive hazard re-estimates λ from a moving average of detected changepoint intervals, dynamically adjusting the hazard. Signals fire when changepoint probability exceeds threshold + peaks + new segment direction. State updates occur on confirmed bars only to avoid repainting.
⚙️ Recommended Settings & Tuning Guide
Expected Run Length (λ) 50 is a starting point — larger for rare-reversal instruments and higher timeframes, smaller for frequently-flipping ones. Adaptive Hazard Learning ON is recommended to auto-learn the instrument's rhythm. Max Run Length Tracked 60 is a compute trade-off; raise to track longer regimes at higher cost. Changepoint Probability Threshold 0.25 baseline; 0.15 more sensitive, 0.4 stricter. Prior Variance / Observation Noise Variance tune the predictive distribution; raise Observation Noise for noisy instruments. Direction Confirmation 3 sets reversal-direction sensitivity.
💡 How to Use in Practice
Apply to chart and changepoints print luminous vertical lines with BUY/SELL labels. The glowing sub-band below price shows changepoint probability in real time — the hotter it glows, the nearer a reversal. The HUD's RUN-LENGTH DIST section is most important: high r=0 (reset) probability means a reversal is imminent, while dense r=21+ means a stable trend continues — read market state from the distribution shape. A sudden drop in expected run-length is a reversal precursor. The adaptive λ value tells you how many bars, on average, this instrument runs between reversals. Combining with other trend indicators and entering only when changepoint probability is high is effective.
⚠️ Important Notes
This is a truncated approximation of BOCPD (run-length truncated at Max) using a Gaussian predictive likelihood (a simplification of the full Student-t conjugate). The adaptive hazard is a heuristic estimate. It is classical sequential Bayesian inference — not deep Bayesian methods or machine learning — but the core BOCPD recursion is faithful to the original paper. Changepoint probability indicates the "possibility" of a reversal, not a certain prediction. Estimates become unstable in extreme volatility or with little initial data. Compute scales with the run-length limit; lower Max Run Length Tracked if it's heavy.
🚨 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-SHIFT detects trend reversals as a probability using Bayesian Online Changepoint Detection (BOCPD, Adams & MacKay 2007). Rather than "did a moving average cross?", it asks "what is the probability that the current price regime just ended?" — computing a full posterior distribution over how long the current trend has lasted (run-length). An adaptive layer learns the hazard (reversal frequency) online from the spacing between changepoints, auto-adapting to each instrument's rhythm.
🔶 Key Features
Faithful BOCPD: sequential Bayesian update of the run-length posterior
Gaussian predictive likelihood + Welford online statistics: probabilistic evaluation of each regime hypothesis
Adaptive hazard learning: auto-estimates expected run-length λ from changepoint intervals
Quantifies changepoint probability 0-100%: clear reversal signal
Multi-layer glow rendering: luminous vertical lines at changepoints
Run-length distribution mini-heatmap: visualizes the distribution shape in the HUD
Probability-linked background pulse and segment trend line
BUY/SELL markers + per-event alerts
🧠 Technical Architecture
This implements the core BOCPD algorithm. Each bar maintains P(run-length = r | data) for r = 0..Rmax, with each hypothesis carrying Welford online statistics (mean/variance) of returns inside the segment. For each new observation, a Gaussian predictive likelihood π(x|r) is computed, weighted by the hazard function H = 1/λ, propagated forward (growth: r→r+1), with changepoint mass collapsed to r=0 and normalized. P(r=0) is the changepoint probability. Observations are ATR-normalized returns for scale stability. Adaptive hazard re-estimates λ from a moving average of detected changepoint intervals, dynamically adjusting the hazard. Signals fire when changepoint probability exceeds threshold + peaks + new segment direction. State updates occur on confirmed bars only to avoid repainting.
⚙️ Recommended Settings & Tuning Guide
Expected Run Length (λ) 50 is a starting point — larger for rare-reversal instruments and higher timeframes, smaller for frequently-flipping ones. Adaptive Hazard Learning ON is recommended to auto-learn the instrument's rhythm. Max Run Length Tracked 60 is a compute trade-off; raise to track longer regimes at higher cost. Changepoint Probability Threshold 0.25 baseline; 0.15 more sensitive, 0.4 stricter. Prior Variance / Observation Noise Variance tune the predictive distribution; raise Observation Noise for noisy instruments. Direction Confirmation 3 sets reversal-direction sensitivity.
💡 How to Use in Practice
Apply to chart and changepoints print luminous vertical lines with BUY/SELL labels. The glowing sub-band below price shows changepoint probability in real time — the hotter it glows, the nearer a reversal. The HUD's RUN-LENGTH DIST section is most important: high r=0 (reset) probability means a reversal is imminent, while dense r=21+ means a stable trend continues — read market state from the distribution shape. A sudden drop in expected run-length is a reversal precursor. The adaptive λ value tells you how many bars, on average, this instrument runs between reversals. Combining with other trend indicators and entering only when changepoint probability is high is effective.
⚠️ Important Notes
This is a truncated approximation of BOCPD (run-length truncated at Max) using a Gaussian predictive likelihood (a simplification of the full Student-t conjugate). The adaptive hazard is a heuristic estimate. It is classical sequential Bayesian inference — not deep Bayesian methods or machine learning — but the core BOCPD recursion is faithful to the original paper. Changepoint probability indicates the "possibility" of a reversal, not a certain prediction. Estimates become unstable in extreme volatility or with little initial data. Compute scales with the run-length limit; lower Max Run Length Tracked if it's heavy.
🚨 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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.