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
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.