OPEN-SOURCE SCRIPT
Statistical Deviation per Asset

INDICATOR: STATISTICAL DEVIATION PER ASSET (SDPA)
1. Overview
The Statistical Deviation per Asset (SDPA) is a quantitative analysis tool designed to measure the strength and exhaustion of price movements. Unlike standard oscillators (like RSI), the SDPA calculates the actual percentage deviation from the most recent pivot point (High or Low) and compares it against historical performance averages specific to each asset.
---
2. Core Logic & Calculation
The script operates on a Mean Reversion principle. It assumes that every asset (Gold, Bitcoin, Ethereum, etc.) has a unique "volatility signature" depending on the timeframe.
* Dynamic Pivot Detection: The indicator identifies recent Swing Highs and Swing Lows using an adaptive lookback period.
* Real-Time Return Calculation: Once a pivot is confirmed, the script calculates the real-time percentage gain (from a Low) or loss (from a High).
* Zero-Indexed Histogram: This return is plotted as an oscillator centered around a Zero Line, representing the current trend's progress since the last reversal.
---
3. Adaptive Intelligence (Multi-Asset & Multi-TF)
The SDPA is pre-loaded with a statistical database. It automatically adjusts its sensitivity and thresholds based on:
1. The Selected Asset: Whether trading XAUUSD, Bitcoin, or Solana, the deviation thresholds adapt to the specific volatility of that instrument.
2. The Timeframe (TF): The calculation period (period) and performance targets (hausse_perf / baisse_perf) change dynamically. For example, a 1-minute scalping setup uses a longer lookback (200) compared to a Daily swing setup (10).
---
4. Visual Anatomy
The interface is designed for instant "at-a-glance" interpretation:
* The Histogram:
* Green: Price is trending up since the last Swing Low.
* Red: Price is trending down since the last Swing High.
* Threshold Lines (The Statistical Averages):
* Thick Line (60% Opacity): Represents the Average Historical Deviation. When the histogram hits this line, the move is considered "statistically mature."
* Thin Line (70% Opacity): Represents the Strong Deviation Zone (1.5x the average), indicating extreme momentum or potential exhaustion.
* Background Highlighting: The chart background colors automatically when the price exceeds historical averages, signaling a High-Probability Reversal Zone.
---
5. How to Trade with SDPA
* Trend Maturity: If the histogram exceeds the Bullish Average (Green line), the current move has reached its typical historical limit. Traders should look for take-profit opportunities or wait for a reversal.
* Impulse Strength: A rapid move from the Zero Line toward the thresholds confirms strong institutional interest.
* Mean Reversion: When the histogram reaches the Strong Zone (1.5x), the price is "overextended" statistically, offering a high reward-to-risk ratio for counter-trend setups.
---
6. Technical Parameters
* Asset Choice: Dropdown menu to select the specific asset.
* Colors: Customizable Bullish and Bearish colors to match any UI theme.
* Precision: Set to 4 decimal places to ensure accuracy across all asset types.
1. Overview
The Statistical Deviation per Asset (SDPA) is a quantitative analysis tool designed to measure the strength and exhaustion of price movements. Unlike standard oscillators (like RSI), the SDPA calculates the actual percentage deviation from the most recent pivot point (High or Low) and compares it against historical performance averages specific to each asset.
---
2. Core Logic & Calculation
The script operates on a Mean Reversion principle. It assumes that every asset (Gold, Bitcoin, Ethereum, etc.) has a unique "volatility signature" depending on the timeframe.
* Dynamic Pivot Detection: The indicator identifies recent Swing Highs and Swing Lows using an adaptive lookback period.
* Real-Time Return Calculation: Once a pivot is confirmed, the script calculates the real-time percentage gain (from a Low) or loss (from a High).
* Zero-Indexed Histogram: This return is plotted as an oscillator centered around a Zero Line, representing the current trend's progress since the last reversal.
---
3. Adaptive Intelligence (Multi-Asset & Multi-TF)
The SDPA is pre-loaded with a statistical database. It automatically adjusts its sensitivity and thresholds based on:
1. The Selected Asset: Whether trading XAUUSD, Bitcoin, or Solana, the deviation thresholds adapt to the specific volatility of that instrument.
2. The Timeframe (TF): The calculation period (period) and performance targets (hausse_perf / baisse_perf) change dynamically. For example, a 1-minute scalping setup uses a longer lookback (200) compared to a Daily swing setup (10).
---
4. Visual Anatomy
The interface is designed for instant "at-a-glance" interpretation:
* The Histogram:
* Green: Price is trending up since the last Swing Low.
* Red: Price is trending down since the last Swing High.
* Threshold Lines (The Statistical Averages):
* Thick Line (60% Opacity): Represents the Average Historical Deviation. When the histogram hits this line, the move is considered "statistically mature."
* Thin Line (70% Opacity): Represents the Strong Deviation Zone (1.5x the average), indicating extreme momentum or potential exhaustion.
* Background Highlighting: The chart background colors automatically when the price exceeds historical averages, signaling a High-Probability Reversal Zone.
---
5. How to Trade with SDPA
* Trend Maturity: If the histogram exceeds the Bullish Average (Green line), the current move has reached its typical historical limit. Traders should look for take-profit opportunities or wait for a reversal.
* Impulse Strength: A rapid move from the Zero Line toward the thresholds confirms strong institutional interest.
* Mean Reversion: When the histogram reaches the Strong Zone (1.5x), the price is "overextended" statistically, offering a high reward-to-risk ratio for counter-trend setups.
---
6. Technical Parameters
* Asset Choice: Dropdown menu to select the specific asset.
* Colors: Customizable Bullish and Bearish colors to match any UI theme.
* Precision: Set to 4 decimal places to ensure accuracy across all asset types.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
My Website for the traders !
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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
My Website for the traders !
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.