PROTECTED SOURCE SCRIPT

Z-Score du Graphique Actuel

15
Indicator: Z-Score for Active Chart (Custom Spreads)
Description
This simple yet powerful indicator calculates and displays the Z-Score for the active chart.
It is specifically designed for traders who manually create and chart spreads (e.g., "MNQ1!-1.17*MES1!" or "AAPL-MSFT") directly in the TradingView symbol bar. Instead of requiring you to input multiple symbols into the indicator's settings, this script simply reads the closing price of whatever chart it is applied to.
This makes it a fast and efficient tool for analyzing the mean-reversion properties of any custom-built spread.
Key Features
• Simplicity: Works directly on the chart's current price (close). No complex inputs are needed.
• Ideal for Spreads: Perfect for pairs trading or analyzing custom spreads (futures, stocks, crypto, etc.) that you type into the main symbol input.
• Customizable Length: Set the lookback period (z_length) for the Z-Score calculation (which determines the simple moving average and standard deviation).
• Visual Trading Zones: The script plots customizable dashed lines for your entry thresholds (long and short) and dotted lines for your exit thresholds.
• Background Highlighting: The background changes color (red for short zone, green for long zone) when the Z-Score moves beyond your specified entry thresholds, providing a clear visual signal for potential over-extension.
How to Use
1. Create Your Spread: Go to the TradingView symbol bar at the top of your screen.
2. Type Your Formula: Type in your custom spread formula (e.g., MNQ1!-1.17*MES1!, AAPL-MSFT, or BTCUSD-ETHUSD). Press Enter.
3. Apply the Indicator: Add this "Z-Score (Chart)" indicator to the resulting spread chart.
4. Analyze: The indicator will instantly plot the Z-Score of your custom spread's price.
5. Adjust Settings: Go into the indicator's settings to adjust the Z-Score lookback period and your preferred entry/exit levels to match your trading strategy.
Inputs
• Z-Score Period: The lookback period (default 40) used to calculate the moving average and standard deviation.
• Short Entry Threshold: The positive Z-Score level (e.g., 1.8) above which you might consider a short position.
• Short Exit Threshold: The Z-Score level (e.g., 0.5) at which you might close a short position as it reverts to the mean.
• Long Entry Threshold: The negative Z-Score level (e.g., -1.8) below which you might consider a long position.
• Long Exit Threshold: The Z-Score level (e.g., -0.5) at which you might close a long position as it reverts to the mean.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.