OPEN-SOURCE SCRIPT
Extended SOPR Indicator — SSOPR Tops (A/B toggle)

Extended SOPR Indicator — SSOPR Tops and Lows (A/B toggle)
Observation-only. Data: Glassnode SOPR.
Overview
This indicator extends the classical SOPR (Spent Output Profit Ratio) to improve readability and reduce noise on charts. SOPR measures whether coins moved on-chain were spent at a profit or at a loss. In brief: SOPR > 1 → spending at profit; SOPR < 1 → spending at loss. SSOPR (from "Smoothed SOPR") applies optional log transform (centers baseline at 0), smoothing (standard or adaptive), and adds structured signals: Z‑score lows (capitulation), buy zones, and top detection after prolonged elevation.
Why extend SOPR? (SSOPR vs classical SOPR)
• Noise reduction: Raw daily SOPR can whipsaw around its baseline. SSOPR uses smoothing and (optionally) adaptive smoothing so regimes are visible without overfitting.
• Better readability: The log transform shifts the break-even line to 0, making “profit territory” (above 0) and “loss territory” (below 0) visually intuitive on oscillators.
• Actionable context: Z‑score highlights extreme lows (capitulation risk), a simple buy-zone threshold marks potential accumulation, and a structured top pattern (with a time factor) helps frame distribution phases after sustained elevation.
What the script plots
• Smoothed SOPR (SSOPR): An orange line representing the smoothed SOPR (with optional log transform and optional adaptive smoothing).
• Top markers: A red triangle appears once at the onset of a confirmed top pattern.
• Background shading:
– Soft green: Buy zone when SSOPR falls below the “Buy Threshold.” (+ Z‑score capitulation zones (extreme lows)).
– Soft red: Top‑zone shading when the top criteria are met but before the single triangle fires.
Inputs & parameters
• Smoothing Length (default 14): Base window for smoothing SSOPR. Higher values = smoother, slower response.
• Apply Log Transform (default ON): Uses log(SOPR) so the baseline is 0 (log(1)=0). Above 0 → net profit regime; below 0 → net loss regime.
• Adaptive Smoothing (default OFF): Expands smoothing length as volatility rises using a standard deviation proxy; reduces whipsaws while preserving structure.
• Z‑score Threshold for Lows (default −2.5): Highlights capitulation zones when SSOPR deviates far below its rolling mean.
• SSOPR Buy Threshold (default −0.02): Simple rule-of-thumb level for potential accumulation context when below (log scale).
• SSOPR Top Threshold (default +0.005): Minimum elevation required for “profit territory” when assessing tops (log scale).
• Min Bars Above Threshold Before Top (default 50): Ensures prolonged elevation before calling a top.
• Lookback for Peak Detection (default 50): Window used to locate the recent high.
• Drop % from Peak to Confirm Top (default 5%): Confirms the start of distribution from a local high.
• Highlight Background: Toggles shaded zones.
Top detection (indicator-only)
A top fires when ALL of the following are true:
Rising‑phase switch: Option A vs Option B
• Option A — Up‑step ratio: Over the last A: Bars for Rising Check (default 50), it requires that at least A: Required Up‑Step Ratio (default 60%) of bars were rising (each bar compared to the previous). This favors gradual, persistent advances and filters out “choppy” lifts.
• Option B — Net slope: Compares current SSOPR to its value B: Bars Back for Net Slope ago (default 50). If higher, the series is considered rising. This is simpler and reacts faster in volatile phases but can admit brief pseudo‑trends.
Guidance: Prefer A for conservative confirmation in slow, persistent cycles; use B when trend moves are strong and you need timely detection.
Interpretation guide
• Regimes (log view): Above 0 → spending at profit; below 0 → spending at loss.
• Capitulation lows: When Z‑score < threshold, conditions often reflect forced/liquidity‑driven spending. Treat as context, not signals.
• Buy zone: SSOPR < Buy Threshold flags potential accumulation conditions (combine with price structure).
• Tops: After prolonged elevation, a confirmed top often coincides with profit‑taking/distribution phases.
Recommended timeframes
• Daily: Code optimized for daily timeframe.
Method summary
• SSOPR source: GLASSNODE:BTC_SOPR (via request.security).
• Optional log transform: sopr → log(sopr) to normalize around 0.
• Smoothing: SMA over Smoothing Length, optionally adaptive using local volatility (std dev).
• Z‑score: (SSOPR − mean) / std dev, highlighting extreme lows.
• Top: Requires long elevation above Top Threshold, rising‑phase (A/B), and a subsequent drop > Drop % from recent high.
Limitations & notes
• SOPR reflects on‑chain movements; some activity occurs off‑chain (exchanges, internal transfers). Not all moves imply sale; aggregation makes it a usable proxy for profit/loss realization.
• Higher smoothing reduces noise but delays signals; adaptive smoothing can help but is still a trade‑off.
• Treat thresholds as context markers. They are not entry/exit signals by themselves.
• Use with price structure, volume, and other on‑chain indicators (e.g., realized price bands, dormancy/CDD) for confluence.
How to use (examples)
• Advance holding above 0 (log view): Retests of 0 from above that hold—while SSOPR remains elevated—often mark absorption; look for Top conditions only after sustained elevation and a confirmed drop from peak.
• Downtrend below 0: Rejections near 0 can align with continued loss realization; extreme Z‑score lows suggest capitulation risk—context for accumulation, not a blind buy.
Recommended settings
• Weekly: Log ON, Smoothing Length 14–30, Adaptive ON, Buy Threshold −0.02, Top Threshold +0.005, Rising Method A, Min Bars 50.
• Daily: Log ON, Smoothing Length 14–20, Adaptive OFF or ON (depending on noise), Rising Method B for timely slope checks.
Credits & references
• SOPR metric: Renato Shirakashi; documentation: Glassnode, CryptoQuant, overview: Bitbo.
Disclaimer
This script is for research/education on market behavior. It is not financial advice. Indicators provide context; decisions remain your responsibility.
Tags
bitcoin, btc, on‑chain, sopr, ssopr, glassnode, oscillator, regime, distribution, capitulation
Observation-only. Data: Glassnode SOPR.
Overview
This indicator extends the classical SOPR (Spent Output Profit Ratio) to improve readability and reduce noise on charts. SOPR measures whether coins moved on-chain were spent at a profit or at a loss. In brief: SOPR > 1 → spending at profit; SOPR < 1 → spending at loss. SSOPR (from "Smoothed SOPR") applies optional log transform (centers baseline at 0), smoothing (standard or adaptive), and adds structured signals: Z‑score lows (capitulation), buy zones, and top detection after prolonged elevation.
Why extend SOPR? (SSOPR vs classical SOPR)
• Noise reduction: Raw daily SOPR can whipsaw around its baseline. SSOPR uses smoothing and (optionally) adaptive smoothing so regimes are visible without overfitting.
• Better readability: The log transform shifts the break-even line to 0, making “profit territory” (above 0) and “loss territory” (below 0) visually intuitive on oscillators.
• Actionable context: Z‑score highlights extreme lows (capitulation risk), a simple buy-zone threshold marks potential accumulation, and a structured top pattern (with a time factor) helps frame distribution phases after sustained elevation.
What the script plots
• Smoothed SOPR (SSOPR): An orange line representing the smoothed SOPR (with optional log transform and optional adaptive smoothing).
• Top markers: A red triangle appears once at the onset of a confirmed top pattern.
• Background shading:
– Soft green: Buy zone when SSOPR falls below the “Buy Threshold.” (+ Z‑score capitulation zones (extreme lows)).
– Soft red: Top‑zone shading when the top criteria are met but before the single triangle fires.
Inputs & parameters
• Smoothing Length (default 14): Base window for smoothing SSOPR. Higher values = smoother, slower response.
• Apply Log Transform (default ON): Uses log(SOPR) so the baseline is 0 (log(1)=0). Above 0 → net profit regime; below 0 → net loss regime.
• Adaptive Smoothing (default OFF): Expands smoothing length as volatility rises using a standard deviation proxy; reduces whipsaws while preserving structure.
• Z‑score Threshold for Lows (default −2.5): Highlights capitulation zones when SSOPR deviates far below its rolling mean.
• SSOPR Buy Threshold (default −0.02): Simple rule-of-thumb level for potential accumulation context when below (log scale).
• SSOPR Top Threshold (default +0.005): Minimum elevation required for “profit territory” when assessing tops (log scale).
• Min Bars Above Threshold Before Top (default 50): Ensures prolonged elevation before calling a top.
• Lookback for Peak Detection (default 50): Window used to locate the recent high.
• Drop % from Peak to Confirm Top (default 5%): Confirms the start of distribution from a local high.
• Highlight Background: Toggles shaded zones.
Top detection (indicator-only)
A top fires when ALL of the following are true:
- SSOPR spent at leastMin Bars Above Threshold above the Top Threshold (sustained elevation).
- The rising phase test passes (Option A or B; see below).
- A drop from the local peak exceeds Drop % within the Lookback window.
- The peak occurred in profit territory (SSOPR > Top Threshold).
- To avoid repeated signals during the decline, the script emits the triangle once, at onset.
Rising‑phase switch: Option A vs Option B
• Option A — Up‑step ratio: Over the last A: Bars for Rising Check (default 50), it requires that at least A: Required Up‑Step Ratio (default 60%) of bars were rising (each bar compared to the previous). This favors gradual, persistent advances and filters out “choppy” lifts.
• Option B — Net slope: Compares current SSOPR to its value B: Bars Back for Net Slope ago (default 50). If higher, the series is considered rising. This is simpler and reacts faster in volatile phases but can admit brief pseudo‑trends.
Guidance: Prefer A for conservative confirmation in slow, persistent cycles; use B when trend moves are strong and you need timely detection.
Interpretation guide
• Regimes (log view): Above 0 → spending at profit; below 0 → spending at loss.
• Capitulation lows: When Z‑score < threshold, conditions often reflect forced/liquidity‑driven spending. Treat as context, not signals.
• Buy zone: SSOPR < Buy Threshold flags potential accumulation conditions (combine with price structure).
• Tops: After prolonged elevation, a confirmed top often coincides with profit‑taking/distribution phases.
Recommended timeframes
• Daily: Code optimized for daily timeframe.
Method summary
• SSOPR source: GLASSNODE:BTC_SOPR (via request.security).
• Optional log transform: sopr → log(sopr) to normalize around 0.
• Smoothing: SMA over Smoothing Length, optionally adaptive using local volatility (std dev).
• Z‑score: (SSOPR − mean) / std dev, highlighting extreme lows.
• Top: Requires long elevation above Top Threshold, rising‑phase (A/B), and a subsequent drop > Drop % from recent high.
Limitations & notes
• SOPR reflects on‑chain movements; some activity occurs off‑chain (exchanges, internal transfers). Not all moves imply sale; aggregation makes it a usable proxy for profit/loss realization.
• Higher smoothing reduces noise but delays signals; adaptive smoothing can help but is still a trade‑off.
• Treat thresholds as context markers. They are not entry/exit signals by themselves.
• Use with price structure, volume, and other on‑chain indicators (e.g., realized price bands, dormancy/CDD) for confluence.
How to use (examples)
• Advance holding above 0 (log view): Retests of 0 from above that hold—while SSOPR remains elevated—often mark absorption; look for Top conditions only after sustained elevation and a confirmed drop from peak.
• Downtrend below 0: Rejections near 0 can align with continued loss realization; extreme Z‑score lows suggest capitulation risk—context for accumulation, not a blind buy.
Recommended settings
• Weekly: Log ON, Smoothing Length 14–30, Adaptive ON, Buy Threshold −0.02, Top Threshold +0.005, Rising Method A, Min Bars 50.
• Daily: Log ON, Smoothing Length 14–20, Adaptive OFF or ON (depending on noise), Rising Method B for timely slope checks.
Credits & references
• SOPR metric: Renato Shirakashi; documentation: Glassnode, CryptoQuant, overview: Bitbo.
Disclaimer
This script is for research/education on market behavior. It is not financial advice. Indicators provide context; decisions remain your responsibility.
Tags
bitcoin, btc, on‑chain, sopr, ssopr, glassnode, oscillator, regime, distribution, capitulation
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。