OPEN-SOURCE SCRIPT
Z-Score Pro

Z-Score Pro - Complete Description
This is an **advanced mean reversion indicator** that measures how many standard deviations the current price is from its average. It's ideal for identifying market extremes and trading opportunities.
What is the Z-Score?
The Z-Score is a statistical measure that answers: **"How far is the price from normal?"**
- **Z = 0**: Price is at its average
- **Z = +2**: Price is 2 standard deviations above (overbought)
- **Z = -2**: Price is 2 standard deviations below (oversold)
- **Z > +3** or **Z < -3**: Very rare extremes (occur ~0.3% of the time)
Main Features
### 1. **Flexible Calculation**
- **SMA or EMA**: Choose between simple or exponential moving average
- **Adjustable period**: Default 20 periods
- **Smoothing**: Option to smooth the Z-Score to reduce noise
### 2. **Multiple Levels**
- **±1.0**: Caution zone
- **±2.0**: Overbought/Oversold (68% statistical confidence)
- **±3.0**: Rare extremes (99.7% statistical confidence)
### 3. **Trading Signals**
The indicator generates automatic signals based on:
**Buy Signals (BUY)**:
- Z-Score is in oversold zone
- Momentum changes from negative to positive (price stops falling)
**Sell Signals (SELL)** :
- Z-Score is in overbought zone
- Momentum changes from positive to negative (price stops rising)
**Aggressiveness Levels**:
- **Conservative**: Only signals at extremes (±3.0)
- **Normal**: Signals at ±2.0 (recommended)
- **Aggressive**: More frequent signals at ±1.5
### 4. **Divergence Detection**
**Bullish Divergence** (aqua marker):
- Price makes a lower low
- Z-Score makes a higher low
- Indicates weakening of downtrend
**Bearish Divergence** (fuchsia marker):
- Price makes a higher high
- Z-Score makes a lower high
- Indicates weakening of uptrend
---
## Visualization
### Dynamic Colors
- **Bright red**: Z-Score > 2 and rising (strong overbought)
- **Orange**: Z-Score > 1 and rising
- **Purple**: Neutral zone rising
- **Transparent green**: Z-Score falling (any level)
### Background Zones
- **Intense red**: Extreme overbought (Z > 3)
- **Soft orange**: Overbought (Z > 2)
- **Intense green**: Extreme oversold (Z < -3)
- **Soft lime**: Oversold (Z < -2)
### Info Table (top right corner)
Shows in real-time:
- **Current Z-Score**: Numeric value with color
- **Status**: Extreme OB/OS, Overbought, Oversold, or Neutral
- **Momentum**: Rising ↗ or Falling ↘
- **Mean**: Current average value
- **Std Dev**: Current standard deviation
---
## Alert System
The indicator includes **8 types of alerts**:
1. **Buy Signal**: When entry conditions are met
2. **Sell Signal**: When exit conditions are met
3. **Overbought**: When crossing above +2.0
4. **Oversold**: When crossing below -2.0
5. **Extreme Overbought**: When reaching +3.0
6. **Extreme Oversold**: When reaching -3.0
7. **Bullish Divergence**: Potential reversal up
8. **Bearish Divergence**: Potential reversal down
---
## How to Use It
### **Mean Reversion Strategy**
1. Wait for Z-Score to reach ±2 or beyond
2. Wait for BUY/SELL signal (momentum reversal)
3. Enter trade in opposite direction of extreme
4. Exit when Z-Score returns to zero
### **Divergence Strategy**
1. Identify divergence markers (DIV)
2. Confirm with momentum change
3. Enter in direction of divergence
4. Use Z-Score levels as targets
### **Multi-Timeframe Analysis**
- **Short-term** (5-15 min): Scalping with aggressive mode
- **Medium-term** (1H-4H): Swing trading with normal mode
- **Long-term** (Daily): Position trading with conservative mode
---
## Best Practices
**Do**:
- Use in ranging/sideways markets
- Combine with support/resistance levels
- Wait for momentum confirmation
- Use conservative mode in trending markets
**Don't**:
- Trade against strong trends
- Ignore divergences
- Use alone without confirmation
- Over-trade in low volatility
---
## Statistical Background
The Z-Score follows a **normal distribution**:
- **68%** of values fall within ±1 standard deviation
- **95%** of values fall within ±2 standard deviations
- **99.7%** of values fall within ±3 standard deviations
When price reaches Z = ±2, there's a **95% probability** it will revert toward the mean, making it a powerful mean reversion tool.
---
##Customization Options
All aspects are customizable:
- Calculation method and periods
- Visual colors and transparency
- Signal sensitivity
- Alert preferences
- Level thresholds
- Background zones on/off
This is an **advanced mean reversion indicator** that measures how many standard deviations the current price is from its average. It's ideal for identifying market extremes and trading opportunities.
What is the Z-Score?
The Z-Score is a statistical measure that answers: **"How far is the price from normal?"**
- **Z = 0**: Price is at its average
- **Z = +2**: Price is 2 standard deviations above (overbought)
- **Z = -2**: Price is 2 standard deviations below (oversold)
- **Z > +3** or **Z < -3**: Very rare extremes (occur ~0.3% of the time)
Main Features
### 1. **Flexible Calculation**
- **SMA or EMA**: Choose between simple or exponential moving average
- **Adjustable period**: Default 20 periods
- **Smoothing**: Option to smooth the Z-Score to reduce noise
### 2. **Multiple Levels**
- **±1.0**: Caution zone
- **±2.0**: Overbought/Oversold (68% statistical confidence)
- **±3.0**: Rare extremes (99.7% statistical confidence)
### 3. **Trading Signals**
The indicator generates automatic signals based on:
**Buy Signals (BUY)**:
- Z-Score is in oversold zone
- Momentum changes from negative to positive (price stops falling)
**Sell Signals (SELL)** :
- Z-Score is in overbought zone
- Momentum changes from positive to negative (price stops rising)
**Aggressiveness Levels**:
- **Conservative**: Only signals at extremes (±3.0)
- **Normal**: Signals at ±2.0 (recommended)
- **Aggressive**: More frequent signals at ±1.5
### 4. **Divergence Detection**
**Bullish Divergence** (aqua marker):
- Price makes a lower low
- Z-Score makes a higher low
- Indicates weakening of downtrend
**Bearish Divergence** (fuchsia marker):
- Price makes a higher high
- Z-Score makes a lower high
- Indicates weakening of uptrend
---
## Visualization
### Dynamic Colors
- **Bright red**: Z-Score > 2 and rising (strong overbought)
- **Orange**: Z-Score > 1 and rising
- **Purple**: Neutral zone rising
- **Transparent green**: Z-Score falling (any level)
### Background Zones
- **Intense red**: Extreme overbought (Z > 3)
- **Soft orange**: Overbought (Z > 2)
- **Intense green**: Extreme oversold (Z < -3)
- **Soft lime**: Oversold (Z < -2)
### Info Table (top right corner)
Shows in real-time:
- **Current Z-Score**: Numeric value with color
- **Status**: Extreme OB/OS, Overbought, Oversold, or Neutral
- **Momentum**: Rising ↗ or Falling ↘
- **Mean**: Current average value
- **Std Dev**: Current standard deviation
---
## Alert System
The indicator includes **8 types of alerts**:
1. **Buy Signal**: When entry conditions are met
2. **Sell Signal**: When exit conditions are met
3. **Overbought**: When crossing above +2.0
4. **Oversold**: When crossing below -2.0
5. **Extreme Overbought**: When reaching +3.0
6. **Extreme Oversold**: When reaching -3.0
7. **Bullish Divergence**: Potential reversal up
8. **Bearish Divergence**: Potential reversal down
---
## How to Use It
### **Mean Reversion Strategy**
1. Wait for Z-Score to reach ±2 or beyond
2. Wait for BUY/SELL signal (momentum reversal)
3. Enter trade in opposite direction of extreme
4. Exit when Z-Score returns to zero
### **Divergence Strategy**
1. Identify divergence markers (DIV)
2. Confirm with momentum change
3. Enter in direction of divergence
4. Use Z-Score levels as targets
### **Multi-Timeframe Analysis**
- **Short-term** (5-15 min): Scalping with aggressive mode
- **Medium-term** (1H-4H): Swing trading with normal mode
- **Long-term** (Daily): Position trading with conservative mode
---
## Best Practices
**Do**:
- Use in ranging/sideways markets
- Combine with support/resistance levels
- Wait for momentum confirmation
- Use conservative mode in trending markets
**Don't**:
- Trade against strong trends
- Ignore divergences
- Use alone without confirmation
- Over-trade in low volatility
---
## Statistical Background
The Z-Score follows a **normal distribution**:
- **68%** of values fall within ±1 standard deviation
- **95%** of values fall within ±2 standard deviations
- **99.7%** of values fall within ±3 standard deviations
When price reaches Z = ±2, there's a **95% probability** it will revert toward the mean, making it a powerful mean reversion tool.
---
##Customization Options
All aspects are customizable:
- Calculation method and periods
- Visual colors and transparency
- Signal sensitivity
- Alert preferences
- Level thresholds
- Background zones on/off
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.