Correlation & Mean Reversion - Paired Stocks/ETFs (By MC)

🔍 Key Functions:
Price Ratio Analysis
Calculates and monitors the price ratio (A/B) between two user-defined tickers over a rolling period.
Z-Score Calculation
Measures how far the current ratio deviates from its mean in standard deviation units (Z-score), with safeguards against unstable values.
Mean Reversion Probability
Uses a normal distribution function to estimate the likelihood of the ratio reverting to its mean — shown as a percentage.
Rolling Correlation
Computes the correlation of log returns between the two instruments to gauge relationship strength.
| Correlation Value | Interpretation |
| ----------------- | ----------------------------- |
| +1.0 | Perfect positive correlation (price of both move in the same direction)|
| +0.7 to +0.9 | Strong positive correlation |
| +0.4 to +0.6 | Moderate positive correlation |
| 0 | No correlation (independent) |
| -0.4 to -0.6 | Moderate negative correlation |
| -0.7 to -0.9 | Strong negative correlation |
| -1.0 | Perfect negative correlation (price both move in the opposite direction)|
Trade Signal Alerts
🔴 Strong Mean Reversion if probability > 95%
🟡 Moderate Mean Reversion if probability > 80%
- % Reversion >= 0.9 - "High"
- % Reversion >= 0.8 - "Moderate High"
- % Reversion >= 0.6 - "Low"
- % Reversion < 0.6 "Very Low"
Color-Coded Backgrounds & Signal Markers
Visual indicators appear on the chart to flag potential trade setups.
Stats Table (Mobile-Optimized)
Displays:
Symbol A & B
Ratio
Z-Score
Mean Reversion %
Rolling Correlation
Trade Quality: High, Moderate High, Low, or Very Low (color-coded)
User Customization
Table position (top/bottom left/right)
Toggle display of plots (Z-score, correlation, ratio overlay)
Chart style for mean reversion % (line/histogram)
🎯 Use Case:
This tool is ideal for pair traders looking to exploit statistical arbitrage opportunities by entering trades when price relationships deviate from their historical norm.
Updated calculation method now shows probability of mean reversion (the closer to zero, the more likely to revert) using two-sided p-value (twice the tail area).
Updated calculation method now shows probability of mean reversion (0-100 %) using two-sided p-value (twice the tail area).
Yalnızca davetli komut dosyası
Bu komut dosyasına yalnızca yazar tarafından yetkilendirilen kullanıcılar erişebilir ve bu genellikle ödeme gerektirir. Bu komut dosyasını favorilerinize ekleyebilirsiniz, ancak yalnızca yazarından izin istedikten ve aldıktan sonra kullanabilirsiniz — daha fazla bilgi burada. Daha fazla ayrıntı için yazarın aşağıdaki talimatlarını izleyin veya doğrudan mclee1.2006 ile iletişime geçin.
TradingView, yazarına tam olarak güvenmediğiniz ve nasıl çalıştığını anlamadığınız sürece bir komut dosyası için ödeme yapmanızı veya kullanmanızı ÖNERMEZ. Ayrıca topluluk komut dosyaları bölümümüzde ücretsiz, açık kaynaklı alternatifler bulabilirsiniz.
Yazarın talimatları
Uyarı: Erişim talebinde bulunmadan önce lütfen yalnızca davetli komut dosyaları kılavuzumuzu okuyun.
Feragatname
Yalnızca davetli komut dosyası
Bu komut dosyasına yalnızca yazar tarafından yetkilendirilen kullanıcılar erişebilir ve bu genellikle ödeme gerektirir. Bu komut dosyasını favorilerinize ekleyebilirsiniz, ancak yalnızca yazarından izin istedikten ve aldıktan sonra kullanabilirsiniz — daha fazla bilgi burada. Daha fazla ayrıntı için yazarın aşağıdaki talimatlarını izleyin veya doğrudan mclee1.2006 ile iletişime geçin.
TradingView, yazarına tam olarak güvenmediğiniz ve nasıl çalıştığını anlamadığınız sürece bir komut dosyası için ödeme yapmanızı veya kullanmanızı ÖNERMEZ. Ayrıca topluluk komut dosyaları bölümümüzde ücretsiz, açık kaynaklı alternatifler bulabilirsiniz.
Yazarın talimatları
Uyarı: Erişim talebinde bulunmadan önce lütfen yalnızca davetli komut dosyaları kılavuzumuzu okuyun.