PROTECTED SOURCE SCRIPT

momentum spread strategy ilker

15
This script is the opposite of a traditional mean-reversion pairs trading strategy. It is a "Cointegration Breakdown" or "Momentum Divergence" tool.
Instead of betting on a spread's Z-Score to revert to 0, this strategy is designed to identify when the statistical relationship (the "elastic band") has snapped. It then provides signals to trade with the momentum as the spread diverges.
It filters for true breakouts by waiting for a "Momentum Regime," which is confirmed only when the pair's relationship becomes statistically unstable.
## 📈 Key Features
1. The Momentum Regime (Blue Background)
This is the core of the indicator. The background turns BLUE to signal a "Momentum Regime". This is the only time you should look for a momentum trade.
The blue background activates only if TWO conditions are met simultaneously:
• 1. Relationship Instability: The pair's relationship is broken. This is confirmed when either the rolling Correlation Z-Score (purple line) breaks down OR the Volatility Ratio (orange line) becomes unstable.
• 2. Divergence Confirmation: The Half-Life calculation (from our v2.8 script) shows "N/A (Divergent)" in the dashboard. This mathematically confirms the mean-reverting force (\lambda) is gone (it has turned positive) and the spread is statistically diverging.
If the background is GRAY, the script is in a "Neutral" or "Mean-Reversion" state, and all momentum signals should be ignored.
2. Momentum Breakout Signals
This strategy inverts the Z-Score logic. The 0-line is not a profit target; it is the breakout line.
• BUY Signal (Blue Triangle ▲): Appears only if the background is BLUE and the Z-Score (blue line) crosses ABOVE 0. This is your long momentum entry.
• SELL Signal (Fuchsia Triangle ▼): Appears only if the background is BLUE and the Z-Score crosses BELOW 0. This is your short momentum entry.
3. Built-in Trade Management
• Take Profit (X Cross): Your profit target is the outer band. The script plots an 'X' when the Z-Score hits the +2.0 band (for longs) or the -2.0 band (for shorts).
• Stop Loss (X Cross): Your stop is a failure of the momentum. The script plots an 'X' if the Z-Score re-crosses the 0-line against your trade.
4. Full Quant Dashboard
All the statistical components are plotted for analysis:
• Price Z-Score (Blue Line): Your primary momentum indicator.
• Z-Score Correlation (Purple Line): Lets you visually confirm the correlation breakdown.
• Volatility Ratio (Orange Line): Lets you visually confirm the volatility spike.
• Half-Life Dashboard: Confirms the regime by showing "N/A (Divergent)".
## 🛠 How to Use (Required Setup)
IMPORTANT: This indicator is designed to run on a spread chart (e.g., M2K/MES or MGC/SIL).
1. Load your spread chart first (e.g., type M2K/MES in the ticker bar).
2. Add this indicator to the chart.
3. Go into the indicator's Settings (⚙).
4. In the "Inputs" tab, you MUST fill in the two individual tickers:
• Ticker du Symbole 1 (REQUIS): M2K
• Ticker du Symbole 2 (REQUIS): MES
5. The script uses these two inputs to calculate the Volatility and Correlation filters. The main Z-Score is calculated from the spread chart itself.
This tool is for traders who want to capture explosive divergence moves that happen during fundamental news or regime changes, while filtering out the "noise" of stable, mean-reverting periods.

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。